How to use tldts - 5 common examples

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,
github microlinkhq / browserless / packages / goto / src / index.js View on Github external
const parseCookies = (url, str) => {
  const domain = `.${getDomain(url)}`
  return str.split(';').reduce((acc, str) => {
    const [name, value] = str.split('=')
    const cookie = {
      name: name.trim(),
      value,
      domain,
      url,
      path: '/'
    }
    return [...acc, cookie]
  }, [])
}
github cliqz-oss / adblocker / bench / macro.js View on Github external
    ({ url, sourceUrl }) => ((getHostname(url || '') || '').length + (getHostname(sourceUrl || '') || '').length) > 0,
    requests,

tldts

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

MIT
Latest version published 1 day ago

Package Health Score

85 / 100
Full package analysis