MCPcopy Index your code
hub / github.com/webpack/css-loader / normalizeUrl

Function normalizeUrl

src/utils.js:420–453  ·  view source on GitHub ↗
(url, isStringValue)

Source from the content-addressed store, hash-verified

418const NATIVE_WIN32_PATH = /^[A-Z]:[/\\]|^\\\\/i;
419
420function normalizeUrl(url, isStringValue) {
421 let normalizedUrl = url
422 .replace(/^( |\t\n|\r\n|\r|\f)*/g, "")
423 .replace(/( |\t\n|\r\n|\r|\f)*$/g, "");
424
425 if (isStringValue && /\\(\n|\r\n|\r|\f)/.test(normalizedUrl)) {
426 normalizedUrl = normalizedUrl.replace(/\\(\n|\r\n|\r|\f)/g, "");
427 }
428
429 if (NATIVE_WIN32_PATH.test(url)) {
430 try {
431 normalizedUrl = decodeURI(normalizedUrl);
432 } catch (error) {
433 // Ignore
434 }
435
436 return normalizedUrl;
437 }
438
439 normalizedUrl = unescape(normalizedUrl);
440
441 if (isDataUrl(url)) {
442 // Todo fixedEncodeURIComponent is workaround. Webpack resolver shouldn't handle "!" in dataURL
443 return fixedEncodeURIComponent(normalizedUrl);
444 }
445
446 try {
447 normalizedUrl = decodeURI(normalizedUrl);
448 } catch (error) {
449 // Ignore
450 }
451
452 return normalizedUrl;
453}
454
455function requestify(url, rootContext, needToResolveURL = true) {
456 if (needToResolveURL) {

Callers 3

parseNodeFunction · 0.90
OnceExitFunction · 0.90
parseDeclarationFunction · 0.90

Calls 3

unescapeFunction · 0.85
isDataUrlFunction · 0.85
fixedEncodeURIComponentFunction · 0.85

Tested by

no test coverage detected