How to use url-toolkit - 9 common examples

To help you get started, we’ve selected a few url-toolkit 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 eclipse / thingweb.node-wot / packages / td-tools / src / td-parser.ts View on Github external
// check if base field required
        if (!isAbsoluteUrl(form.href) && !thing.hasOwnProperty("base")) throw new Error(`Form of ${interactionPatterns[pattern]} '${interaction}' has relative URI while TD has no base field`);
        // add
        allForms.push(form);
      }
    }
  }

  if (thing.hasOwnProperty("base")) {
    if (normalize === undefined || normalize === true) {
      console.log(`parseTD() normalizing 'base' into 'forms'`);

      for (let form of allForms) {
        if (!form.href.match(/^([a-z0-9\+-\.]+\:).+/i)) {
          console.debug(`parseTDString() applying base '${thing.base}' to '${form.href}'`);
          form.href = URLToolkit.buildAbsoluteURL(thing.base, form.href);
        }
      }
    }
  }

  return thing;
}
github mozilla / hubs / src / components / media-views.js View on Github external
xhrSetup: (xhr, u) => {
            if (u.startsWith(corsProxyPrefix)) {
              u = u.substring(corsProxyPrefix.length);
            }

            // HACK HLS.js resolves relative urls internally, but our CORS proxying screws it up. Resolve relative to the original unproxied url.
            // TODO extend HLS.js to allow overriding of its internal resolving instead
            if (!u.startsWith("http")) {
              u = buildAbsoluteURL(baseUrl, u.startsWith("/") ? u : `/${u}`);
            }

            xhr.open("GET", proxiedUrlFor(u));
          }
        });
github videojs / http-streaming / test / test-helpers.js View on Github external
export const absoluteUrl = function(relativeUrl) {
  return URLToolkit.buildAbsoluteURL(window.location.href, relativeUrl);
};
github tjenkinson / mock-hls-server / src / mock-hls-server.js View on Github external
_rewriteUrl(baseUrl, url, throughProxy = true) {
        const absoluteURL = UrlToolkit.buildAbsoluteURL(baseUrl, url, { alwaysNormalize: true });
        return (
            '# Original URL: ' +
            url +
            '\r\n' +
            (
                throughProxy
                ? this._proxyBaseUrl + querystring.escape(absoluteURL)
                : absoluteURL
            )
        );
    }
github tjenkinson / mock-hls-server / src / mock-hls-server.js View on Github external
return line.replace(/URI="(.*?)"/g, (match) => {
            const url = match.slice(5, -1);
            const absoluteURL = UrlToolkit.buildAbsoluteURL(baseUrl, url, { alwaysNormalize: true });
            return 'URI="' + this._proxyBaseUrl + querystring.escape(absoluteURL) + '"';
        });
    }
github video-dev / hls.js / src / loader / m3u8-parser.js View on Github external
static resolve (url, baseUrl) {
    return URLToolkit.buildAbsoluteURL(baseUrl, url, { alwaysNormalize: true });
  }
github video-dev / hls.js / src / loader / playlist-loader.js View on Github external
get uri() {
    if (!this._uri && this.reluri) {
      this._uri = URLToolkit.buildAbsoluteURL(this.baseuri, this.reluri);
    }
    return this._uri;
  }
github video-dev / hls.js / src / loader / level-key.js View on Github external
get uri () {
    if (!this._uri && this.reluri) {
      this._uri = URLToolkit.buildAbsoluteURL(this.baseuri, this.reluri, { alwaysNormalize: true });
    }

    return this._uri;
  }
}
github video-dev / hls.js / src / loader / playlist-loader.js View on Github external
resolve(url, baseUrl) {
    return URLToolkit.buildAbsoluteURL(baseUrl, url);
  }

url-toolkit

Build an absolute URL from a base URL and a relative URL (RFC 1808). No dependencies!

Apache-2.0
Latest version published 3 years ago

Package Health Score

60 / 100
Full package analysis

Popular url-toolkit functions