How to use the tldts.parse function in tldts

To help you get started, we’ve selected a few tldts 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 dot-browser / desktop / src / main / view.ts View on Github external
this.webContents.addListener('did-start-navigation', (...args: any[]) => {
      this.updateNavigationState();

      const url = this.webContents.getURL();

      const { styles, scripts } = engine.getCosmeticsFilters({
        url,
        ...parse(url),
      });

      this.webContents.insertCSS(styles);

      for (const script of scripts) {
        this.webContents.executeJavaScript(script);
      }

      // appWindow.webContents.send(`load-commit-${this.tabId}`, ...args);

      this.emitWebNavigationEvent('onBeforeNavigate', {
        tabId: this.tabId,
        url: this.webContents.getURL(),
        frameId: 0,
        timeStamp: Date.now(),
        processId: process.pid,
github cliqz-oss / adblocker / src / request / raw.ts View on Github external
export function processRawRequest(request: IRawRequest) {
  // Extract hostname
  const url = request.url.toLowerCase();
  const { host, domain } = parse(url);

  // Process source url
  let sourceUrl = request.sourceUrl;
  let sourceHostname = '';
  let sourceDomain = '';

  if (sourceUrl) {
    // It can happen when source is not a valid URL, then we simply
    // leave `sourceHostname` and `sourceGD` as empty strings to allow
    // some filter matching on the request URL itself.
    sourceUrl = sourceUrl.toLowerCase();
    const sourceUrlParts = parse(sourceUrl);
    sourceHostname = sourceUrlParts.host || '';
    sourceDomain = sourceUrlParts.domain || '';
  }
github cliqz-oss / adblocker / src / request / raw.ts View on Github external
export function processRawRequest(request: IRawRequest) {
  // Extract hostname
  const url = request.url.toLowerCase();
  const { host, domain } = parse(url);

  // Process source url
  let sourceUrl = request.sourceUrl;
  let sourceHostname = '';
  let sourceDomain = '';

  if (sourceUrl) {
    // It can happen when source is not a valid URL, then we simply
    // leave `sourceHostname` and `sourceGD` as empty strings to allow
    // some filter matching on the request URL itself.
    sourceUrl = sourceUrl.toLowerCase();
    const sourceUrlParts = parse(sourceUrl);
    sourceHostname = sourceUrlParts.host || '';
    sourceDomain = sourceUrlParts.domain || '';
  }

  // Wrap informations needed to match the request
  return mkRequest({
    cpt: request.cpt,

    // SourceUrl
    sourceDomain,
    sourceHostname,

    // Url
    domain: domain || '',
    hostname: host || '',
    url,

tldts

Library to work against complex domain names, subdomains and URIs.

MIT
Latest version published 14 days ago

Package Health Score

83 / 100
Full package analysis