github.com/nektos/act@v0.2.63/pkg/runner/testdata/actions/node12/node_modules/whatwg-url/lib/URL.js (about)

     1  "use strict";
     2  
     3  const conversions = require("webidl-conversions");
     4  const utils = require("./utils.js");
     5  const Impl = require(".//URL-impl.js");
     6  
     7  const impl = utils.implSymbol;
     8  
     9  function URL(url) {
    10    if (!this || this[impl] || !(this instanceof URL)) {
    11      throw new TypeError("Failed to construct 'URL': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
    12    }
    13    if (arguments.length < 1) {
    14      throw new TypeError("Failed to construct 'URL': 1 argument required, but only " + arguments.length + " present.");
    15    }
    16    const args = [];
    17    for (let i = 0; i < arguments.length && i < 2; ++i) {
    18      args[i] = arguments[i];
    19    }
    20    args[0] = conversions["USVString"](args[0]);
    21    if (args[1] !== undefined) {
    22    args[1] = conversions["USVString"](args[1]);
    23    }
    24  
    25    module.exports.setup(this, args);
    26  }
    27  
    28  URL.prototype.toJSON = function toJSON() {
    29    if (!this || !module.exports.is(this)) {
    30      throw new TypeError("Illegal invocation");
    31    }
    32    const args = [];
    33    for (let i = 0; i < arguments.length && i < 0; ++i) {
    34      args[i] = arguments[i];
    35    }
    36    return this[impl].toJSON.apply(this[impl], args);
    37  };
    38  Object.defineProperty(URL.prototype, "href", {
    39    get() {
    40      return this[impl].href;
    41    },
    42    set(V) {
    43      V = conversions["USVString"](V);
    44      this[impl].href = V;
    45    },
    46    enumerable: true,
    47    configurable: true
    48  });
    49  
    50  URL.prototype.toString = function () {
    51    if (!this || !module.exports.is(this)) {
    52      throw new TypeError("Illegal invocation");
    53    }
    54    return this.href;
    55  };
    56  
    57  Object.defineProperty(URL.prototype, "origin", {
    58    get() {
    59      return this[impl].origin;
    60    },
    61    enumerable: true,
    62    configurable: true
    63  });
    64  
    65  Object.defineProperty(URL.prototype, "protocol", {
    66    get() {
    67      return this[impl].protocol;
    68    },
    69    set(V) {
    70      V = conversions["USVString"](V);
    71      this[impl].protocol = V;
    72    },
    73    enumerable: true,
    74    configurable: true
    75  });
    76  
    77  Object.defineProperty(URL.prototype, "username", {
    78    get() {
    79      return this[impl].username;
    80    },
    81    set(V) {
    82      V = conversions["USVString"](V);
    83      this[impl].username = V;
    84    },
    85    enumerable: true,
    86    configurable: true
    87  });
    88  
    89  Object.defineProperty(URL.prototype, "password", {
    90    get() {
    91      return this[impl].password;
    92    },
    93    set(V) {
    94      V = conversions["USVString"](V);
    95      this[impl].password = V;
    96    },
    97    enumerable: true,
    98    configurable: true
    99  });
   100  
   101  Object.defineProperty(URL.prototype, "host", {
   102    get() {
   103      return this[impl].host;
   104    },
   105    set(V) {
   106      V = conversions["USVString"](V);
   107      this[impl].host = V;
   108    },
   109    enumerable: true,
   110    configurable: true
   111  });
   112  
   113  Object.defineProperty(URL.prototype, "hostname", {
   114    get() {
   115      return this[impl].hostname;
   116    },
   117    set(V) {
   118      V = conversions["USVString"](V);
   119      this[impl].hostname = V;
   120    },
   121    enumerable: true,
   122    configurable: true
   123  });
   124  
   125  Object.defineProperty(URL.prototype, "port", {
   126    get() {
   127      return this[impl].port;
   128    },
   129    set(V) {
   130      V = conversions["USVString"](V);
   131      this[impl].port = V;
   132    },
   133    enumerable: true,
   134    configurable: true
   135  });
   136  
   137  Object.defineProperty(URL.prototype, "pathname", {
   138    get() {
   139      return this[impl].pathname;
   140    },
   141    set(V) {
   142      V = conversions["USVString"](V);
   143      this[impl].pathname = V;
   144    },
   145    enumerable: true,
   146    configurable: true
   147  });
   148  
   149  Object.defineProperty(URL.prototype, "search", {
   150    get() {
   151      return this[impl].search;
   152    },
   153    set(V) {
   154      V = conversions["USVString"](V);
   155      this[impl].search = V;
   156    },
   157    enumerable: true,
   158    configurable: true
   159  });
   160  
   161  Object.defineProperty(URL.prototype, "hash", {
   162    get() {
   163      return this[impl].hash;
   164    },
   165    set(V) {
   166      V = conversions["USVString"](V);
   167      this[impl].hash = V;
   168    },
   169    enumerable: true,
   170    configurable: true
   171  });
   172  
   173  
   174  module.exports = {
   175    is(obj) {
   176      return !!obj && obj[impl] instanceof Impl.implementation;
   177    },
   178    create(constructorArgs, privateData) {
   179      let obj = Object.create(URL.prototype);
   180      this.setup(obj, constructorArgs, privateData);
   181      return obj;
   182    },
   183    setup(obj, constructorArgs, privateData) {
   184      if (!privateData) privateData = {};
   185      privateData.wrapper = obj;
   186  
   187      obj[impl] = new Impl.implementation(constructorArgs, privateData);
   188      obj[impl][utils.wrapperSymbol] = obj;
   189    },
   190    interface: URL,
   191    expose: {
   192      Window: { URL: URL },
   193      Worker: { URL: URL }
   194    }
   195  };
   196