UNPKG

axios

Version:

Promise based HTTP client for the browser and node.js

25 lines (19 loc) 473 B
'use strict'; const urlParserControlCharacters = /[\t\n\r]/g; /** * Match WHATWG URL preprocessing before checking a URL's protocol. * * @param {string} url * * @returns {string} */ export default function normalizeURLForProtocolCheck(url) { if (typeof url !== 'string') { return url; } let start = 0; while (start < url.length && url.charCodeAt(start) <= 0x20) { start++; } return url.slice(start).replace(urlParserControlCharacters, ''); }