Skip to content

Commit

Permalink
add end spaces in all scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
jonluca committed Mar 6, 2024
1 parent 5db51d8 commit fb49854
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/util/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ export const parse = (u: string | URL) => new URL(u);
export function resolve(from: string, to: string) {
const fromUrl = new URL(convertPathToPosix(from), "resolve://");
const resolvedUrl = new URL(convertPathToPosix(to), fromUrl);
const endSpaces = to.match(/(\s*)$/)?.[1] || "";
if (resolvedUrl.protocol === "resolve:") {
// `from` is a relative URL.
const { pathname, search, hash } = resolvedUrl;
const endSpaces = to.match(/(\s*)$/)?.[1] || "";

return pathname + search + hash + endSpaces;
}
return resolvedUrl.toString();
return resolvedUrl.toString() + endSpaces;
}

/**
Expand Down

0 comments on commit fb49854

Please sign in to comment.