Kong/insomnia · error · TypeError

Invalid URL: ${url}

Error message

Invalid URL: ${url}

What it means

Error "Invalid URL: ${url}" thrown in Kong/insomnia.

Source

Thrown at packages/insomnia/src/templating/sandbox/sandbox-globals.ts:252

  '    USP.prototype.has = function (k) { return this.get(k) !== null; };',
  '    USP.prototype["delete"] = function (k) { k = String(k); for (var i = this._p.length - 1; i >= 0; i--) { if (this._p[i][0] === k) { this._p.splice(i, 1); } } };',
  '    USP.prototype.forEach = function (cb, thisArg) { for (var i = 0; i < this._p.length; i++) { cb.call(thisArg, this._p[i][1], this._p[i][0], this); } };',
  '    USP.prototype.sort = function () { this._p.sort(function (a, b) { return a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0; }); };',
  '    USP.prototype.toString = function () {',
  '      var parts = []; for (var i = 0; i < this._p.length; i++) { parts.push(__enc(this._p[i][0]) + "=" + __enc(this._p[i][1])); } return parts.join("&");',
  '    };',
  '    globalThis.URLSearchParams = USP;',
  '  }',

  // --- URL (pragmatic absolute-URL parser covering the common WHATWG surface) ---
  // Parses scheme://[host[:port]][/path][?query][#hash]. Sufficient for the "new URL(str).<part>"
  // and ".searchParams" usage plugins rely on; relative-URL resolution is out of scope for M2.
  '  if (typeof globalThis.URL === "undefined") {',
  '    var __defaultPorts = { "http:": "80", "https:": "443", "ftp:": "21", "ws:": "80", "wss:": "443" };',
  '    var URLShim = function (input, base) {',
  '      var url = String(input);',
  '      var m = /^([a-zA-Z][a-zA-Z0-9+.-]*:)(\\/\\/)?([^\\/?#]*)([^?#]*)(\\?[^#]*)?(#.*)?$/.exec(url);',
  '      if (!m) { throw new TypeError("Invalid URL: " + url); }',
  '      this.protocol = m[1].toLowerCase();',
  '      var authority = m[3] || "";',
  '      var at = authority.lastIndexOf("@");',
  '      if (at !== -1) {',
  '        var creds = authority.slice(0, at); authority = authority.slice(at + 1);',
  '        var ci = creds.indexOf(":");',
  '        this.username = ci === -1 ? creds : creds.slice(0, ci);',
  '        this.password = ci === -1 ? "" : creds.slice(ci + 1);',
  '      } else { this.username = ""; this.password = ""; }',
  '      var colon = authority.indexOf(":");',
  '      if (colon === -1) { this.hostname = authority.toLowerCase(); this.port = ""; }',
  '      else { this.hostname = authority.slice(0, colon).toLowerCase(); this.port = authority.slice(colon + 1); }',
  '      if (this.port !== "" && __defaultPorts[this.protocol] === this.port) { this.port = ""; }',
  '      this.host = this.port === "" ? this.hostname : this.hostname + ":" + this.port;',
  '      this.pathname = m[4] || (authority ? "/" : "");',
  '      this.search = m[5] || "";',
  '      this.hash = m[6] || "";',
  '      this.searchParams = new globalThis.URLSearchParams(this.search);',

View on GitHub (pinned to d9bb2b0142)

When it happens

Trigger: Thrown at packages/insomnia/src/templating/sandbox/sandbox-globals.ts:252 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Kong/insomnia@d9bb2b0142 (2026-08-26). Data as JSON: /api/errors/9deff29335ff636b. Report an issue: GitHub.