MCPcopy
hub / github.com/nodejs/undici / getProtocolFromUrlString

Function getProtocolFromUrlString

lib/core/util.js:926–944  ·  view source on GitHub ↗

* @param {string} urlString * @returns {string}

(urlString)

Source from the content-addressed store, hash-verified

924 * @returns {string}
925 */
926function getProtocolFromUrlString (urlString) {
927 if (
928 urlString[0] === 'h' &&
929 urlString[1] === 't' &&
930 urlString[2] === 't' &&
931 urlString[3] === 'p'
932 ) {
933 switch (urlString[4]) {
934 case ':':
935 return 'http:'
936 case 's':
937 if (urlString[5] === ':') {
938 return 'https:'
939 }
940 }
941 }
942 // fallback if none of the usual suspects
943 return urlString.slice(0, urlString.indexOf(':') + 1)
944}
945
946const kEnumerableProperty = {
947 __proto__: null,

Callers 1

constructorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…