Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {ContentOrigin} from './content_origin';
import {MapAndPath, RawSourceMap, SourceMapInfo} from './raw_source_map';
import {SourceFile} from './source_file';

const SCHEME_MATCHER = /^([a-z][a-z0-9.-]*):\/\//i;
const SCHEME_MATCHER = /^([a-z][a-z0-9.-]*):\/\/(.*)$/i;

/**
* This class can be used to load a source file, its associated source map and any upstream sources.
Expand Down Expand Up @@ -193,8 +193,11 @@ export class SourceFileLoader {
const sourceRoot = this.fs.resolve(
this.fs.dirname(basePath), this.replaceSchemeWithPath(map.sourceRoot || ''));
return map.sources.map((source, index) => {
const path = this.fs.resolve(sourceRoot, this.replaceSchemeWithPath(source));
const content = map.sourcesContent && map.sourcesContent[index] || null;
const path = this.fs.resolve(
sourceRoot,
content !== null ? this.fs.basename(source) : this.replaceSchemeWithPath(source));

// The origin of this source file is "inline" if we extracted it from the source-map's
// `sourcesContent`, except when the source-map itself was "provided" in-memory.
// An inline source file is treated as if it were from the file-system if the source-map that
Expand Down Expand Up @@ -265,6 +268,8 @@ export class SourceFileLoader {
*/
private replaceSchemeWithPath(path: string): string {
return path.replace(
SCHEME_MATCHER, (_: string, scheme: string) => this.schemeMap[scheme.toLowerCase()] || '');
SCHEME_MATCHER,
(_: string, scheme: string, rest: string) =>
this.fs.join(this.schemeMap[scheme.toLowerCase()] || '/', rest));
}
}
Loading