(url, isStringValue)
| 418 | const NATIVE_WIN32_PATH = /^[A-Z]:[/\\]|^\\\\/i; |
| 419 | |
| 420 | function 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 | |
| 455 | function requestify(url, rootContext, needToResolveURL = true) { |
| 456 | if (needToResolveURL) { |
no test coverage detected