integration: use href from git-url-parse when resolving file urls
When parsing a URL with a trailing slash, git-url-parse drops the trailing slash from the href and filepath properties on the result, which is inconsistent with the behavior of the native URL constructor. Since before we were using the filepath property from git-url-parse to determine how much to truncate the pathname from the URL constructor, we were off-by-one for URLs with a trailing slash. After this change, we pass the href property from git-url-parse to the URL constructor, such that the amount to truncate the pathname and the pathname itself are ultimately coming from the same source. Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/integration': patch
|
||||
---
|
||||
|
||||
Fixed an issue with resolution of SCM URLs against a base URL with a trailing slash.
|
||||
@@ -84,8 +84,10 @@ export function defaultScmResolveUrl(options: {
|
||||
|
||||
if (url.startsWith('/')) {
|
||||
// If it is an absolute path, move relative to the repo root
|
||||
const { filepath } = parseGitUrl(base);
|
||||
updated = new URL(base);
|
||||
const { href, filepath } = parseGitUrl(base);
|
||||
|
||||
updated = new URL(href);
|
||||
|
||||
const repoRootPath = trimEnd(
|
||||
updated.pathname.substring(0, updated.pathname.length - filepath.length),
|
||||
'/',
|
||||
|
||||
Reference in New Issue
Block a user