How to use uri-js - 10 common examples

To help you get started, we’ve selected a few uri-js 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 vimlet / bundl / tests / features / font / node_modules / ajv / lib / compile / resolve.js View on Github external
function resolveSchema(root, ref) {
  /* jshint validthis: true */
  var p = URI.parse(ref)
    , refPath = _getFullPath(p)
    , baseId = getFullPath(this._getId(root.schema));
  if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
    var id = normalizeId(refPath);
    var refVal = this._refs[id];
    if (typeof refVal == 'string') {
      return resolveRecursive.call(this, root, refVal, p);
    } else if (refVal instanceof SchemaObject) {
      if (!refVal.validate) this._compile(refVal);
      root = refVal;
    } else {
      refVal = this._schemas[id];
      if (refVal instanceof SchemaObject) {
        if (!refVal.validate) this._compile(refVal);
        if (id == normalizeId(ref))
          return { schema: refVal, root: root, baseId: baseId };
github codekirei / node-multispinner / extras / examples / cli-with-promises / index.js View on Github external
function download(url, spinnerID, spinners) {
  // if url scheme is undetected, slap an http in front and retry
  if (!uri.parse(url).scheme) {
    return download('http://' + url, spinnerID, spinners)
  }

  // GET request promise
  return axios
    .get(url)
    .then(success => {
      spinners.success(spinnerID)
      return [spinnerID, success]
    })
    .catch(err => {
      // follow redirects
      if (300 < err.status && err.status < 400) {
        return download(err.headers.location, spinnerID, spinners)
      }
      spinners.error(spinnerID)
github travisghansen / external-auth-server / src / plugin / oauth / index.js View on Github external
get_authorization_redirect_uri(uri) {
    const plugin = this;
    const query = {};

    if (plugin.config.redirect_uri) {
      uri = plugin.config.redirect_uri;
    } else {
      // set this in the /oauth/callback endpoint manually to avoid sending non-standard params to providers
      // ie: okta pukes when it sees this
      query[HANDLER_INDICATOR_PARAM_NAME] = "authorization_callback";
    }

    const parsedURI = URI.parse(uri);
    if (Object.keys(query).length) {
      parsedURI.query = queryString.stringify(query);
    }

    return URI.serialize(parsedURI);
  }
github adobe / helix-cli / src / openwhisk / static.js View on Github external
url: (asset) => {
        // TODO pass in request URL and make it absolute.
        if (asset.search === '' && asset.absolutePath !== '.' && asset.relativePath !== '.') {
          return `${asset.relativePath}`;
        }
        return asset.url;
      },
    }));
github whitlockjc / json-refs / index.js View on Github external
// Join the paths
      combinedDetails.path = slash(path.join(u1Details.path, u2Details.path));

      // Join query parameters
      combinedDetails.query = combineQueryParams(u1Details.query, u2Details.query);
    } else {
      combinedDetails = u2Details;
    }
  }

  // Remove the fragment
  combinedDetails.fragment = undefined;

  // For relative URIs, add back the '..' since it was removed above
  return (remoteUriTypes.indexOf(combinedDetails.reference) === -1 &&
          combinedDetails.path.indexOf('../') === 0 ? '../' : '') + URI.serialize(combinedDetails);
}
github vimlet / bundl / tests / features / font / node_modules / ajv / lib / compile / resolve.js View on Github external
function _getFullPath(p) {
  return URI.serialize(p).split('#')[0] + '#';
}
github vimlet / bundl / tests / features / font / node_modules / ajv / lib / compile / resolve.js View on Github external
function resolveUrl(baseId, id) {
  id = normalizeId(id);
  return URI.resolve(baseId, id);
}
github EdgeApp / edge-react-gui / src / components / Main.ui.js View on Github external
doDeepLink (url: string) {
    const parsedUri = URI.parse(url)
    const query = parsedUri.query
    if (!query || !query.includes('token=')) {
      return
    }
    const splitArray = query.split('token=')
    const nextString = splitArray[1]
    const finalArray = nextString.split('&')
    const token = finalArray[0]
    this.props.urlReceived(token)
  }
  handleOpenURL = (event: Object) => {
github adobe / helix-pipeline / src / html / find-embeds.js View on Github external
function embed(uri, node, whitelist = '', debug = () => {}) {
  if ((uri.scheme === 'http' || uri.scheme === 'https') && mm.some(uri.host, whitelist.split(','))) {
    const children = [{ ...node }];
    node.type = 'embed';
    node.children = children;
    node.url = URI.serialize(uri);
    if (node.value) {
      delete node.value;
    }
  } else {
    debug(`Whitelist forbids embedding of URL: ${URI.serialize(uri)}`);
  }
}
github epoberezkin / ajv / lib / compile / resolve.js View on Github external
function _getFullPath(p) {
  return URI.serialize(p).split('#')[0] + '#';
}

uri-js

An RFC 3986/3987 compliant, scheme extendable URI/IRI parsing/validating/resolving library for JavaScript.

BSD-2-Clause
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis