Skip to content

Commit

Permalink
add protocoll check
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankEssenberger committed Oct 17, 2022
1 parent 4dce9ce commit 9b009e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/common/urlUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@ export function completeUrlEscapingRoot(base: string | undefined, relative: stri

export function isValidUrl(url: string): boolean {
try {
new URL(url);
return true;
const parsed = new URL(url);

return parsed.protocol.toLowerCase() == 'http:' || parsed.protocol.toLowerCase() == 'https:';
} catch (e) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/targets/browser/browserPathResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export class BrowserSourcePathResolver extends SourcePathResolverBase<IOptions>
defaultPathMappingResolver,
this.logger,
);
if (isValidUrl(computedSourceRoot) && isValidUrl(url)) {
if (isValidUrl(computedSourceRoot)) {
return new URL(url, computedSourceRoot).href;
}
return properResolve(computedSourceRoot, url);
Expand Down

0 comments on commit 9b009e4

Please sign in to comment.