From 6083217cc0ee70578a9356a1b7f852b6cb46b86a Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 7 Oct 2022 15:10:31 -0700 Subject: [PATCH] Switch to `url-join`. --- components/getRepoUri.ts | 6 ++++-- package.json | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/components/getRepoUri.ts b/components/getRepoUri.ts index 513afc2..c485638 100644 --- a/components/getRepoUri.ts +++ b/components/getRepoUri.ts @@ -1,5 +1,5 @@ -import { join } from 'path-browserify' import { Region, Run } from 'sarif' +import * as urlJoin from 'uri-join' function getHostname(url: string | undefined): string | undefined { if (!url) return undefined @@ -46,7 +46,9 @@ export function getRepoUri(uri: string | undefined, run: Run, region?: Region | // https://github.com/microsoft/sarif-web-component/blob/main/.gitignore // https://github.com/microsoft/sarif-web-component/blob/d14c42f18766159a7ef6fbb8858ab5ad4f0b532a/.gitignore // https://github.com/microsoft/sarif-web-component/blob/d14c42f18766159a7ef6fbb8858ab5ad4f0b532a/.gitignore#L1 - let repoUri = join(`${repositoryUri}/blob/${revisionId ?? 'main'}`, uri) + // Note: path-browserify's path.join does does not preserve authority slashes + // (ex: https://github.com becomes https:/github.com). Thus using url-join. + let repoUri = urlJoin(`${repositoryUri}/blob/${revisionId ?? 'main'}`, uri) if (region?.startLine) { // `startLine` is 1-based. repoUri += `#L${region!.startLine}` } diff --git a/package.json b/package.json index 06e8dad..33578f2 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "@babel/preset-env": "^7.4.5", "@types/enzyme": "3.10.8", "@types/jest": "^24.0.13", - "@types/path-browserify": "^1.0.0", "@types/react": "^16.8.18", "@types/react-dom": "^16.8.4", "@types/sarif": "^2.1.3", @@ -50,9 +49,9 @@ "mobx": "^5.9.4", "mobx-react": "^5.4.4", "mobx-utils": "^5.5.5", - "path-browserify": "^0.0.1", "react-linkify": "^1.0.0-alpha", - "react-markdown": "^4.0.8" + "react-markdown": "^4.0.8", + "uri-join": "^1.0.1" }, "peerDependencies": { "react": "^16.8.6",