How to use the whatwg-url-compat.mixinURLUtils function in whatwg-url-compat

To help you get started, we’ve selected a few whatwg-url-compat 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 / browser / location.js View on Github external
const document = Symbol("relevant document");
const oldParsedURL = Symbol("old parsed URL");

function Location(urlString, relevantDocument) {
  this[document] = relevantDocument;
  whatwgURL.setTheInput(this, urlString);

  try {
    this[oldParsedURL] = new URL(urlString);
  } catch (e) {
    this[oldParsedURL] = {};
  }
}

whatwgURL.mixinURLUtils(
  Location.prototype,
  function getTheBase() {
    return documentBaseURL(this[document]);
  },
  function updateSteps() {
    if (this[oldParsedURL].protocol !== this.protocol ||
        this[oldParsedURL].username !== this.username ||
        this[oldParsedURL].password !== this.password ||
        this[oldParsedURL].hostname !== this.hostname ||
        this[oldParsedURL].port !== this.port ||
        this[oldParsedURL].pathname !== this.pathname ||
        this[oldParsedURL].search !== this.search) {
      notImplemented("navigation via the location interface", this[document]._defaultView);
    } else if (this[oldParsedURL].hash !== this.hash) {
      const window = this[document].defaultView;
      const ev = new window.HashChangeEvent("hashchange", {

whatwg-url-compat

An implementation of the WHATWG URL algorithm

MIT
Latest version published 9 years ago

Package Health Score

63 / 100
Full package analysis

Similar packages