Skip to content

Commit e1e44e4

Browse files
refactor(web): sonar-feedback
1 parent d88445b commit e1e44e4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

web/src/components/FileViewer/index.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,17 @@ const fileNameIfIpfsUrl = (url: string) => {
5454
if (!url || typeof url !== "string") {
5555
return "document";
5656
}
57-
5857
const ipfsPattern = /(?:ipfs:\/\/|https?:\/\/(?:[A-Za-z0-9.-]+)\/ipfs\/)([A-Za-z0-9]+[A-Za-z0-9\-_]*)\/?(.*)/;
5958

60-
const match = url.match(ipfsPattern);
59+
const match = ipfsPattern.exec(url);
6160

6261
if (match) {
6362
const ipfsHash = match[1];
6463
const path = match[2] || "";
6564

6665
const sanitizedPath = path.replace(/\//g, "_");
6766

68-
return `ipfs-${ipfsHash}${sanitizedPath ? `_${sanitizedPath}` : ""}`;
67+
return `ipfs-${ipfsHash}${sanitizedPath ? "_" + sanitizedPath : ""}`;
6968
} else {
7069
return "document";
7170
}

0 commit comments

Comments
 (0)