html-loader
Advanced tools
Comparing version 2.1.1 to 2.1.2
@@ -5,2 +5,9 @@ # Changelog | ||
### [2.1.2](https://github.com/webpack-contrib/html-loader/compare/v2.1.1...v2.1.2) (2021-03-09) | ||
### Bug Fixes | ||
* avoid using `file` protocol ([a309fe0](https://github.com/webpack-contrib/html-loader/commit/a309fe0654972b28d5f9639a97ad993342fb3e85)) | ||
### [2.1.1](https://github.com/webpack-contrib/html-loader/compare/v2.1.0...v2.1.1) (2021-02-24) | ||
@@ -7,0 +14,0 @@ |
@@ -23,3 +23,3 @@ "use strict"; | ||
var _url = require("url"); | ||
var _path = _interopRequireDefault(require("path")); | ||
@@ -816,2 +816,46 @@ var _HtmlSourceError = _interopRequireDefault(require("./HtmlSourceError")); | ||
const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]|^\\\\/; | ||
const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g; | ||
const absoluteToRequest = (context, maybeAbsolutePath) => { | ||
if (maybeAbsolutePath[0] === '/') { | ||
if (maybeAbsolutePath.length > 1 && maybeAbsolutePath[maybeAbsolutePath.length - 1] === '/') { | ||
// this 'path' is actually a regexp generated by dynamic requires. | ||
// Don't treat it as an absolute path. | ||
return maybeAbsolutePath; | ||
} | ||
const querySplitPos = maybeAbsolutePath.indexOf('?'); | ||
let resource = querySplitPos === -1 ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos); | ||
resource = _path.default.posix.relative(context, resource); | ||
if (!resource.startsWith('../')) { | ||
resource = `./${resource}`; | ||
} | ||
return querySplitPos === -1 ? resource : resource + maybeAbsolutePath.slice(querySplitPos); | ||
} | ||
if (WINDOWS_ABS_PATH_REGEXP.test(maybeAbsolutePath)) { | ||
const querySplitPos = maybeAbsolutePath.indexOf('?'); | ||
let resource = querySplitPos === -1 ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos); | ||
resource = _path.default.win32.relative(context, resource); | ||
if (!WINDOWS_ABS_PATH_REGEXP.test(resource)) { | ||
resource = resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, '/'); | ||
if (!resource.startsWith('../')) { | ||
resource = `./${resource}`; | ||
} | ||
} | ||
return querySplitPos === -1 ? resource : resource + maybeAbsolutePath.slice(querySplitPos); | ||
} // not an absolute path | ||
return maybeAbsolutePath; | ||
}; | ||
const contextify = (context, request) => request.split('!').map(r => absoluteToRequest(context, r)).join('!'); | ||
const GET_SOURCE_FROM_IMPORT_NAME = '___HTML_LOADER_GET_SOURCE_FROM_IMPORT___'; | ||
@@ -824,3 +868,3 @@ | ||
const fileURLToHelper = (0, _url.pathToFileURL)(require.resolve('./runtime/getUrl.js')); | ||
const fileURLToHelper = contextify(loaderContext.context, require.resolve('./runtime/getUrl.js')); | ||
let code = options.esModule ? `import ${GET_SOURCE_FROM_IMPORT_NAME} from "${fileURLToHelper}";\n` : `var ${GET_SOURCE_FROM_IMPORT_NAME} = require("${fileURLToHelper}");\n`; | ||
@@ -827,0 +871,0 @@ |
{ | ||
"name": "html-loader", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Html loader module for webpack", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77669
1158