MCPcopy Create free account
hub / github.com/nodejs/node / isValidEncodedURL

Function isValidEncodedURL

deps/undici/src/lib/web/fetch/util.js:62–74  ·  view source on GitHub ↗

* @see https://www.rfc-editor.org/rfc/rfc1738#section-2.2 * @param {string} url * @returns {boolean}

(url)

Source from the content-addressed store, hash-verified

60 * @returns {boolean}
61 */
62function isValidEncodedURL (url) {
63 for (let i = 0; i < url.length; ++i) {
64 const code = url.charCodeAt(i)
65
66 if (
67 code > 0x7E || // Non-US-ASCII + DEL
68 code < 0x20 // Control characters NUL - US
69 ) {
70 return false
71 }
72 }
73 return true
74}
75
76/**
77 * If string contains non-ASCII characters, assumes it's UTF-8 encoded and decodes it.

Callers 1

responseLocationURLFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected