Skip to content
This repository was archived by the owner on Oct 9, 2020. It is now read-only.

Commit 56b2747

Browse files
authored
Merge pull request #135 from papandreou/fix/prependBrowserRootUrlToRootRelative
Fix prepending of loader.browserRootURL to root-relative url
2 parents df7dd77 + 5921059 commit 56b2747

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

css-plugin-base-builder.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,19 @@ exports.bundle = function(loads, compileOpts, outputOpts) {
122122
}
123123
}), atUrl({
124124
url: function(fileName, decl, from, dirname, to, options, result) {
125-
if (absUrl(fileName) || fileName.match(/^%23/))
125+
if ((absUrl(fileName) && fileName.charAt(0) !== '/') || fileName.match(/^%23/))
126126
return fileName;
127127

128128
// dirname may be renormalized to cwd
129129
if (dirname.substr(0, cwd.length + 1) === cwd + path.sep)
130130
dirname = path.resolve(baseURLPath, dirname.substr(cwd.length + 1));
131131

132132
if (loader.rootURL)
133-
return (loader.browserRootURL || '/') + path.relative(loader.rootURL, path.join(dirname, fileName)).replace(/\\/g, '/');
133+
if (fileName.charAt(0) === '/') {
134+
return (loader.browserRootURL || '/') + fileName.replace(/\\/g, '/').replace(/\//, '');
135+
} else {
136+
return (loader.browserRootURL || '/') + path.relative(loader.rootURL, path.join(dirname, fileName)).replace(/\\/g, '/');
137+
}
134138
else
135139
return path.relative(baseURLPath, path.join(dirname, fileName)).replace(/\\/g, '/');
136140
}

0 commit comments

Comments
 (0)