X-Git-Url: https://git.josue.xyz/?p=dotfiles%2F.git;a=blobdiff_plain;f=.config%2Fcoc%2Fextensions%2Fnode_modules%2Fcoc-go%2Fnode_modules%2Fnode-fetch%2Flib%2Findex.es.js;h=79f70d356bb913dc2c8fe4f3181ad9105d44850b;hp=61906c95981eae213a20dbca82d8f9178ade64bd;hb=3be0a9efc698a9570a44456009afc6014812625a;hpb=d2f432cc757f42f0318fdddcab8c00b240d47088 diff --git a/.config/coc/extensions/node_modules/coc-go/node_modules/node-fetch/lib/index.es.js b/.config/coc/extensions/node_modules/coc-go/node_modules/node-fetch/lib/index.es.js index 61906c95..79f70d35 100644 --- a/.config/coc/extensions/node_modules/coc-go/node_modules/node-fetch/lib/index.es.js +++ b/.config/coc/extensions/node_modules/coc-go/node_modules/node-fetch/lib/index.es.js @@ -3,6 +3,7 @@ process.emitWarning("The .es.js file is deprecated. Use .mjs instead."); import Stream from 'stream'; import http from 'http'; import Url from 'url'; +import whatwgUrl from 'whatwg-url'; import https from 'https'; import zlib from 'zlib'; @@ -1137,11 +1138,32 @@ Object.defineProperty(Response.prototype, Symbol.toStringTag, { }); const INTERNALS$2 = Symbol('Request internals'); +const URL = Url.URL || whatwgUrl.URL; // fix an issue where "format", "parse" aren't a named export for node <10 const parse_url = Url.parse; const format_url = Url.format; +/** + * Wrapper around `new URL` to handle arbitrary URLs + * + * @param {string} urlStr + * @return {void} + */ +function parseURL(urlStr) { + /* + Check whether the URL is absolute or not + Scheme: https://tools.ietf.org/html/rfc3986#section-3.1 + Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3 + */ + if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) { + urlStr = new URL(urlStr).toString(); + } + + // Fallback to old implementation for arbitrary URLs + return parse_url(urlStr); +} + const streamDestructionSupported = 'destroy' in Stream.Readable.prototype; /** @@ -1178,14 +1200,14 @@ class Request { // in order to support Node.js' Url objects; though WHATWG's URL objects // will fall into this branch also (since their `toString()` will return // `href` property anyway) - parsedURL = parse_url(input.href); + parsedURL = parseURL(input.href); } else { // coerce input to a string before attempting to parse - parsedURL = parse_url(`${input}`); + parsedURL = parseURL(`${input}`); } input = {}; } else { - parsedURL = parse_url(input.url); + parsedURL = parseURL(input.url); } let method = init.method || input.method || 'GET';