Skip to content

Commit

Permalink
feat: support file: protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Jul 25, 2020
1 parent 5303db2 commit 5604205
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
import { fileURLToPath } from 'url';
import path from 'path';

import { urlToRequest, interpolateName, isUrlRequest } from 'loader-utils';
Expand Down Expand Up @@ -82,6 +83,10 @@ function normalizeUrl(url, isStringValue) {
}

function requestify(url, rootContext) {
if (/^file:/i.test(url)) {
return fileURLToPath(url);
}

return mayBeServerRelativeUrl(url)
? urlToRequest(url, rootContext)
: urlToRequest(url);
Expand Down Expand Up @@ -521,6 +526,10 @@ function isUrlRequestable(url) {
return true;
}

if (/^file:/i.test(url)) {
return true;
}

return isUrlRequest(url);
}

Expand Down

0 comments on commit 5604205

Please sign in to comment.