refactor: hoist RegExps
This commit is contained in:
parent
95f4a3d747
commit
a602d8c2c4
|
@ -133,8 +133,9 @@ function fetchPathsFromFilesystem(
|
|||
* @returns {void}
|
||||
*/
|
||||
function fetchFromURL(fs, context, url, skipReading, callback) {
|
||||
const validProtocolPattern = /^[a-z][a-z0-9+.-]*:/i;
|
||||
// 1. It's an absolute url and it is not `windows` path like `C:\dir\file`
|
||||
if (/^[a-z][a-z0-9+.-]*:/i.test(url) && !path.win32.isAbsolute(url)) {
|
||||
if (validProtocolPattern.test(url) && !path.win32.isAbsolute(url)) {
|
||||
const { protocol } = new urlUtils.URL(url);
|
||||
|
||||
if (protocol === "data:") {
|
||||
|
@ -159,7 +160,8 @@ function fetchFromURL(fs, context, url, skipReading, callback) {
|
|||
}
|
||||
|
||||
// 2. It's a scheme-relative
|
||||
if (/^\/\//.test(url)) {
|
||||
const doubleSlashStartPattern = /^\/\//;
|
||||
if (doubleSlashStartPattern.test(url)) {
|
||||
return callback(
|
||||
new Error(`Failed to parse source map: '${url}' URL is not supported`)
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue