We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d88445b commit e1e44e4Copy full SHA for e1e44e4
web/src/components/FileViewer/index.tsx
@@ -54,18 +54,17 @@ const fileNameIfIpfsUrl = (url: string) => {
54
if (!url || typeof url !== "string") {
55
return "document";
56
}
57
-
58
const ipfsPattern = /(?:ipfs:\/\/|https?:\/\/(?:[A-Za-z0-9.-]+)\/ipfs\/)([A-Za-z0-9]+[A-Za-z0-9\-_]*)\/?(.*)/;
59
60
- const match = url.match(ipfsPattern);
+ const match = ipfsPattern.exec(url);
61
62
if (match) {
63
const ipfsHash = match[1];
64
const path = match[2] || "";
65
66
const sanitizedPath = path.replace(/\//g, "_");
67
68
- return `ipfs-${ipfsHash}${sanitizedPath ? `_${sanitizedPath}` : ""}`;
+ return `ipfs-${ipfsHash}${sanitizedPath ? "_" + sanitizedPath : ""}`;
69
} else {
70
71
0 commit comments