How to use the whatwg-url.serializeURL 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 sx1989827 / DOClever / node_modules / jsdom / lib / jsdom / living / helpers / stylesheets.js View on Github external
} else if (cssRules[i].href) {
      // @import rule: fetch the resource and evaluate it.
      // See http://dev.w3.org/csswg/cssom/#css-import-rule
      //     If loading of the style sheet fails its cssRules list is simply
      //     empty. I.e. an @import rule always has an associated style sheet.
      const parsed = whatwgURL.parseURL(cssRules[i].href, { baseURL });
      if (parsed === null) {
        const window = elementImpl._ownerDocument._defaultView;
        if (window) {
          const error = new Error(`Could not parse CSS @import URL ${cssRules[i].href} relative to base URL ` +
                                  `"${whatwgURL.serializeURL(baseURL)}"`);
          error.type = "css @import URL parsing";
          window._virtualConsole.emit("jsdomError", error);
        }
      } else {
        fetchStylesheetInternal(elementImpl, whatwgURL.serializeURL(parsed), parsed);
      }
    }
  }
}
github flaviuse / mern-authentication / client / node_modules / jsdom / lib / jsdom / living / nodes / HTMLFrameElement-impl.js View on Github external
} else {
      delete frame._contentDocument;
    }
  }

  const parentDoc = frame._ownerDocument;

  // https://html.spec.whatwg.org/#process-the-iframe-attributes
  let url;
  const srcAttribute = getAttributeValue(frame, "src");
  if (srcAttribute === "") {
    url = parseURL("about:blank");
  } else {
    url = parseURL(srcAttribute, { baseURL: documentBaseURL(parentDoc) || undefined }) || parseURL("about:blank");
  }
  const serializedURL = serializeURL(url);

  // This is not great, but prevents a require cycle during webidl2js generation
  const wnd = new parentDoc._defaultView.constructor({
    parsingMode: "html",
    url: url.scheme === "javascript" || serializedURL === "about:blank" ? parentDoc.URL : serializedURL,
    resourceLoader: parentDoc._customResourceLoader,
    userAgent: parentDoc._defaultView.navigator.userAgent,
    referrer: parentDoc.URL,
    cookieJar: parentDoc._cookieJar,
    pool: parentDoc._pool,
    encoding: parentDoc._encoding,
    agentOptions: parentDoc._agentOptions,
    strictSSL: parentDoc._strictSSL,
    proxy: parentDoc._proxy,
    runScripts: parentDoc._defaultView._runScripts,
    commonForOrigin: parentDoc._defaultView._commonForOrigin
github flaviuse / mern-authentication / client / node_modules / jsdom / lib / jsdom / utils.js View on Github external
exports.reflectURLAttribute = (elementImpl, contentAttributeName) => {
  const attributeValue = elementImpl.getAttribute(contentAttributeName);
  if (attributeValue === null || attributeValue === "") {
    return "";
  }

  const urlRecord = parseURLToResultingURLRecord(attributeValue, elementImpl._ownerDocument);
  if (urlRecord === null) {
    return attributeValue;
  }
  return whatwgURL.serializeURL(urlRecord);
};
github jsdom / jsdom / lib / jsdom / living / nodes / HTMLHyperlinkElementUtils-impl.js View on Github external
get href() {
    reinitializeURL(this);
    const { url } = this;

    if (url === null) {
      const href = this.getAttributeNS(null, "href");
      return href === null ? "" : href;
    }

    return whatwgURL.serializeURL(url);
  }
github flaviuse / mern-authentication / client / node_modules / jsdom / lib / jsdom / living / nodes / HTMLLinkElement-impl.js View on Github external
function obtainTheResource(el) {
  const href = el.getAttribute("href");

  if (href === null || href === "") {
    return;
  }

  const url = parseURLToResultingURLRecord(href, el._ownerDocument);
  if (url === null) {
    return;
  }

  const serialized = whatwgURL.serializeURL(url);

  fetchStylesheet(el, serialized);
}
github sx1989827 / DOClever / node_modules / data-urls / lib / parser.js View on Github external
module.exports.fromURLRecord = urlRecord => {
  if (urlRecord.scheme !== "data") {
    return null;
  }

  const input = serializeURL(urlRecord, true).substring("data:".length);

  let position = 0;

  let mimeType = "";
  while (position < input.length && input[position] !== ",") {
    mimeType += input[position];
    ++position;
  }
  mimeType = stripLeadingAndTrailingASCIIWhitespace(mimeType);

  if (position === input.length) {
    return null;
  }

  ++position;
github jsdom / jsdom / lib / jsdom / living / window / SessionHistory.js View on Github external
_fireEvents(stateChanged, hashChanged, state, oldURL, newURL) {
    if (stateChanged) {
      fireAnEvent("popstate", this._windowImpl, PopStateEvent, { state });
    }

    if (hashChanged) {
      fireAnEvent("hashchange", this._windowImpl, HashChangeEvent, {
        oldURL: whatwgURL.serializeURL(oldURL),
        newURL: whatwgURL.serializeURL(newURL)
      });
    }
  }
github jsdom / jsdom / lib / jsdom / living / nodes / HTMLHyperlinkElementUtils-impl.js View on Github external
function updateHref(hheu) {
  hheu.setAttributeNS(null, "href", whatwgURL.serializeURL(hheu.url));
}
github jsdom / jsdom / lib / jsdom / living / window / SessionHistory.js View on Github external
_fireEvents(stateChanged, hashChanged, state, oldURL, newURL) {
    if (stateChanged) {
      fireAnEvent("popstate", this._windowImpl, PopStateEvent, { state });
    }

    if (hashChanged) {
      fireAnEvent("hashchange", this._windowImpl, HashChangeEvent, {
        oldURL: whatwgURL.serializeURL(oldURL),
        newURL: whatwgURL.serializeURL(newURL)
      });
    }
  }