Skip to content

Commit 6b54056

Browse files
add protocol 2
1 parent 9b009e4 commit 6b54056

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/common/urlUtils.ts

+9
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,15 @@ export function completeUrlEscapingRoot(base: string | undefined, relative: stri
199199
}
200200

201201
export function isValidUrl(url: string): boolean {
202+
try {
203+
new URL(url);
204+
return true;
205+
} catch (e) {
206+
return false;
207+
}
208+
}
209+
210+
export function isValidUrlWithProtocol(url: string): boolean {
202211
try {
203212
const parsed = new URL(url);
204213

src/targets/browser/browserPathResolver.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
} from '../../common/sourceMaps/sourceMapResolutionUtils';
2323
import { IUrlResolution } from '../../common/sourcePathResolver';
2424
import * as utils from '../../common/urlUtils';
25-
import { isValidUrl, urlToRegex } from '../../common/urlUtils';
25+
import { isValidUrlWithProtocol, urlToRegex } from '../../common/urlUtils';
2626
import { PathMapping } from '../../configuration';
2727
import { ISourcePathResolverOptions, SourcePathResolverBase } from '../sourcePathResolver';
2828

@@ -205,7 +205,7 @@ export class BrowserSourcePathResolver extends SourcePathResolverBase<IOptions>
205205
defaultPathMappingResolver,
206206
this.logger,
207207
);
208-
if (isValidUrl(computedSourceRoot)) {
208+
if (isValidUrlWithProtocol(computedSourceRoot)) {
209209
return new URL(url, computedSourceRoot).href;
210210
}
211211
return properResolve(computedSourceRoot, url);

0 commit comments

Comments
 (0)