How to use the whatwg-url.serializeURLOrigin function in whatwg-url

To help you get started, we’ve selected a few whatwg-url examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jsdom / jsdom / lib / jsdom / living / websockets / WebSocket-impl.js View on Github external
if (isArrayBuffer(data)) {
        dataForEvent = data;
      } else if (Array.isArray(data)) {
        dataForEvent = copyToArrayBufferInNewRealm(Buffer.concat(data), this._globalObject);
      } else {
        dataForEvent = copyToArrayBufferInNewRealm(data, this._globalObject);
      }
    } else { // this.binaryType === "blob"
      if (!Array.isArray(data)) {
        data = [data];
      }
      dataForEvent = Blob.create(this._globalObject, [data, { type: "" }]);
    }
    fireAnEvent("message", this, MessageEvent, {
      data: dataForEvent,
      origin: serializeURLOrigin(this._urlRecord)
    });
  }
github sx1989827 / DOClever / node_modules / jsdom / lib / jsdom / living / websockets / WebSocket-impl.js View on Github external
dataForEvent = data;
      } else if (Array.isArray(data)) {
        dataForEvent = new Uint8Array(Buffer.concat(data)).buffer;
      } else {
        dataForEvent = new Uint8Array(data).buffer;
      }
    } else { // this.binaryType === "blob"
      if (!Array.isArray(data)) {
        data = [data];
      }
      dataForEvent = Blob.create([data, { type: "" }]);
    }
    this._dispatch(MessageEvent.createImpl([
      "message", {
        data: dataForEvent,
        origin: serializeURLOrigin(this._urlRecord)
      }
    ], { isTrusted: true }));
  }
github sx1989827 / DOClever / node_modules / jsdom / lib / jsdom / living / nodes / HTMLHyperlinkElementUtils-impl.js View on Github external
get origin() {
    reinitializeURL(this);

    if (this.url === null) {
      return "";
    }

    return whatwgURL.serializeURLOrigin(this.url);
  }
github jsdom / jsdom / lib / jsdom / living / websockets / WebSocket-impl-browser.js View on Github external
this._ws.onmessage = event => {
      fireAnEvent("message", this, MessageEvent, {
        data: event.data,
        origin: serializeURLOrigin(this._urlRecord)
      });
    };
github jsdom / jsdom / lib / jsdom / living / nodes / Document-impl.js View on Github external
this._scriptingDisabled = privateData.options.scriptingDisabled;
    if (this._cookieJar === undefined) {
      this._cookieJar = new CookieJar(null, { looseMode: true });
    }

    this.contentType = privateData.options.contentType;
    this._encoding = privateData.options.encoding;

    const urlOption = privateData.options.url === undefined ? "about:blank" : privateData.options.url;
    const parsed = whatwgURL.parseURL(urlOption);
    if (parsed === null) {
      throw new TypeError(`Could not parse "${urlOption}" as a URL`);
    }

    this._URL = parsed;
    this.origin = whatwgURL.serializeURLOrigin(parsed);

    this._location = Location.createImpl(this._globalObject, [], { relevantDocument: this });
    this._history = History.createImpl(this._globalObject, [], {
      window: this._defaultView,
      document: this,
      actAsIfLocationReloadCalled: () => this._location.reload()
    });

    this._workingNodeIterators = [];
    this._workingNodeIteratorsMax = privateData.options.concurrentNodeIterators === undefined ?
                                    10 :
                                    Number(privateData.options.concurrentNodeIterators);

    if (isNaN(this._workingNodeIteratorsMax)) {
      throw new TypeError("The 'concurrentNodeIterators' option must be a Number");
    }
github jsdom / jsdom / lib / api.js View on Github external
reconfigure(settings) {
    if ("windowTop" in settings) {
      this[window]._top = settings.windowTop;
    }

    if ("url" in settings) {
      const document = idlUtils.implForWrapper(this[window]._document);

      const url = whatwgURL.parseURL(settings.url);
      if (url === null) {
        throw new TypeError(`Could not parse "${settings.url}" as a URL`);
      }

      document._URL = url;
      document.origin = whatwgURL.serializeURLOrigin(document._URL);
    }
  }
github sx1989827 / DOClever / node_modules / jsdom / lib / old-api.js View on Github external
exports.changeURL = function (window, urlString) {
  const doc = idlUtils.implForWrapper(window._document);

  const url = whatwgURL.parseURL(urlString);

  if (url === null) {
    throw new TypeError(`Could not parse "${urlString}" as a URL`);
  }

  doc._URL = url;
  doc.origin = whatwgURL.serializeURLOrigin(doc._URL);
};
github jsdom / jsdom / lib / jsdom / living / nodes / HTMLHyperlinkElementUtils-impl.js View on Github external
get origin() {
    reinitializeURL(this);

    if (this.url === null) {
      return "";
    }

    return whatwgURL.serializeURLOrigin(this.url);
  }
github sx1989827 / DOClever / node_modules / jsdom / lib / jsdom / living / websockets / WebSocket-impl-browser.js View on Github external
this._ws.onmessage = event => {
      this._dispatch(MessageEvent.createImpl([
        "message", {
          data: event.data,
          origin: serializeURLOrigin(this._urlRecord)
        }
      ], {
        isTrusted: true
      }));
    };