How to use urijs - 10 common examples

To help you get started, we’ve selected a few urijs 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 cryptowatch / embed / tests / index.js View on Github external
textStrong:   "e5e5e5",
      textWeak:     "7f7f7f",
      short:        "C60606",
      shortFill:    "C60606",
      long:         "00B909",
      longFill:     "000000",
      cta:          "363D52",
      ctaHighlight: "414A67",
      alert:        "FFD506"
    };

    var encodedColors = encodeURIComponent(JSON.stringify(colors));
    var embed = new Embed('bitfinex', 'btcusd', { customColorScheme: colors });
    var uri = new URI(embed.src);
    var encodedColors = uri.query(true)['customColorScheme'];
    var decodedColors = JSON.parse(URI.decodeQuery(encodedColors));

    // Verify that the colors were encoded correctly (order does not matter)
    for (var key in colors) {
      if (colors.hasOwnProperty(key)) {
        assert.equal(colors[key], decodedColors[key]);
      }
    }
  });
github chanzuckerberg / cellxgene / src / reducers / selectedMetadata.js View on Github external
const selectedMetadata = (
  state = {},
  action
) => {
  switch (action.type) {
    case "url changed": {
      const {url} = action;
      const parsed = uri.parseQuery(window.location.search);
      // console.log("onURLchange sees: ", state, parsed)
      return state;
    }
    case "categorical metadata filter selected success": {
      if (!state[action.metadataField]) { /* we don't have the field, which means this is a simple insertion */
        /* {} becomes {Location: ["Tumor"]} */
        return Object.assign({}, state, {[action.metadataField]: [action.value]});
      } else { /* we do have the field, so we need to push to a copy of the array */
        const updatedField = state[action.metadataField].slice()
        updatedField.push(action.value)
        return Object.assign({}, state, {
          /* {Location: ["Tumor"]} becomes {Location: ["Tumor", "Periphery"]} */
          [action.metadataField]: updatedField
        })
      }
    }
github sandialabs / slycat / web-server / plugins / slycat-cca / js / parameter-image-scatterplot-copy.js View on Github external
}

    // If we don't have a session for the image hostname, create one.
    var cached_uri = URI(api_root + "projects/" + self.options.model.project + "/cache/" + URI.encode(uri.host() + uri.path()))

    console.log("Attempting to load image from server-side cache...");
    console.log("Loading image " + image.uri + " from server...");

    var xhr = new XMLHttpRequest();
    var api = "/file";
    if(self.options.video_file_extensions.indexOf(uri.suffix()) > -1) {
      api = "/file";
    }

    xhr.image = image;
    xhr.open("GET", api_root + "projects/" + self.options.model.project + "/cache/" + URI.encode(uri.host() + uri.path()), true);
    xhr.responseType = "arraybuffer";

    xhr.onload = function(e){
      //If the image isn't in cache, open an agent session:
      if (this.status == 404) {
        if(!self.login_open)
        {
          self.login_open = true;
          self.remotes.get_remote({
            hostname: uri.hostname(),
            title: "Login to " + uri.hostname(),
            message: "Loading " + uri.pathname(),
            cancel: function() {
              var jFrame = $(".scaffolding." + image.image_class + "[data-uri=\"" + image.uri + "\"]");
              var frame = d3.select(jFrame[0]);
              var related_frames = jFrame.closest('.media-layer').children('.scaffolding').filter(function(_,x){ return URI($(x).attr("data-uri")).hostname() == uri.hostname(); });
github sandialabs / slycat / web-server / plugins / slycat-parameter-image / js / parameter-image-scatterplot.js View on Github external
}

    // If we don't have a session for the image hostname, create one.
    var cached_uri = URI(api_root + "projects/" + self.options.model.project + "/cache/" + URI.encode(uri.host() + uri.path()))

    console.log("Attempting to load image from server-side cache...");
    console.log("Loading image " + image.uri + " from server...");

    var xhr = new XMLHttpRequest();
    var api = "/file";
    if(self.options.video_file_extensions.indexOf(uri.suffix()) > -1) {
      api = "/file";
    }

    xhr.image = image;
    xhr.open("GET", api_root + "projects/" + self.options.model.project + "/cache/" + URI.encode(uri.host() + uri.path()), true);
    xhr.responseType = "arraybuffer";

    xhr.onload = function(e){
      //If the image isn't in cache, open an agent session:
      if (this.status == 404) {
        if(!self.login_open)
        {
          self.login_open = true;
          self.remotes.get_remote({
            hostname: uri.hostname(),
            title: "Login to " + uri.hostname(),
            message: "Loading " + uri.pathname(),
            cancel: function() {
              var jFrame = $(".scaffolding." + image.image_class + "[data-uri=\"" + image.uri + "\"]");
              var frame = d3.select(jFrame[0]);
              var related_frames = jFrame.closest('.media-layer').children('.scaffolding').filter(function(_,x){ return URI($(x).attr("data-uri")).hostname() == uri.hostname(); });
github apinf / platform / proxy_backends / client / form / form.js View on Github external
proxyHost () {
    // Get a reference of Template instance
    const instance = Template.instance();

    // Get proxy ID from template instance
    const savedProxyId = instance.proxyId;

    // Make sure proxy ID exists or calculate it
    const proxyId = savedProxyId ? savedProxyId.get() : instance.getProxyId();

    // Find the proxy settings
    const proxy = Proxies.findOne(proxyId);

    if (proxy && proxy.apiUmbrella) {
      // Get frontend host from template instance
      const frontend = new URI(proxy.apiUmbrella.url);

      return frontend.host();
    }
    return '';
  },
  oneProxy () {
github sandialabs / slycat / web-server / plugins / slycat-dac / js / dac-ui.js View on Github external
// focus selection color
    var FOCUS_COLOR = "black";

    // scatter plot points (circles or squares)
    var SCATTER_PLOT_TYPE = "circle";

    // variable/metadata inclusion columns
    var var_include_columns = null;
    var meta_include_columns = null;

    // colormap defaults
    var cont_colormap = null;

    // model id from address bar
    var mid = URI(window.location).segment(-1);

    // constants for polling timeouts
    var ONE_MINUTE = 60000;
    var ONE_SECOND = 1000;

    // constants for cutting off plot names, slider names
    var MAX_PLOT_NAME = 20;
    var MAX_SLIDER_NAME = 20;
    var MAX_COLOR_NAME = 20;

    // constant for maximum number of editable column categories
    var MAX_CATS = 50;

    // constant for maximum length of freetext in editable column
    var MAX_FREETEXT_LEN = 500;
github shoutem / extensions / shoutem.rss / server / src / rssPage / reducer.js View on Github external
export function loadFeed(feedUrl) {
  // decode url in case someone encoded it in a way incompatible with legacy server
  const decodedFeedUrl = URI.decode(feedUrl);
  const endpoint = new URI(`//${url.legacy}/v1/apps/${appId}/proxy/resources/${FEED_ITEMS}`)
  .setQuery({
    'filter[url]': decodedFeedUrl,
  })
  .toString();

  const config = {
    schema: FEED_ITEMS,
    request: {
      endpoint,
      headers: {
        Accept: 'application/vnd.api+json',
      },
    },
  };

  return find(config, ext('feedItems'));
github accordproject / concerto / packages / composer-common / lib / model / resourceid.js View on Github external
static fromURI(uri, legacyNamespace, legacyType) {
        let uriComponents;
        try {
            uriComponents = URIJS.parse(uri);
        } catch (err){
            throw new Error('Invalid URI: ' + uri);
        }

        const scheme = uriComponents.protocol;
        // Accept legacy identifiers with missing URI scheme as valid
        if (scheme && scheme !== RESOURCE_SCHEME) {
            throw new Error('Invalid URI scheme: ' + uri);
        }
        if (uriComponents.username || uriComponents.password || uriComponents.port || uriComponents.query) {
            throw new Error('Invalid resource URI format: ' + uri);
        }

        let namespace, type;
        let id = uriComponents.fragment;
        if (!id) {
github astefanutti / kubebox / lib / auth / oidc.js View on Github external
provider_configuration_options() {
    // https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig
    const options = URI.parse(this.auth_provider.url);
    if (this.auth_provider.ca) options.ca = this.auth_provider.ca;
    options.path = URI.joinPaths(options.path, '.well-known/openid-configuration');
    options.protocol += ':';
    return options;
  }
github astefanutti / kubebox / lib / client.js View on Github external
response => {
        const metadata = JSON.parse(response.body.toString('utf8'));
        const { protocol, hostname, port, path } = URI.parse(metadata.authorization_endpoint);
        return new ExternalRequest({
          protocol: protocol + ':',
          hostname,
          port,
          path : `${path}?client_id=openshift-challenging-client&response_type=token`,
          auth : `${username}:${password}`,
          headers: {
            'X-Csrf-Token': '1',
          },
          // Re-use master API client TLS options even if it may be different hosts.
          // It may be necessary to check for sub-domains.
          rejectUnauthorized : this.master_api.rejectUnauthorized,
          secureContext      : this.master_api.secureContext,
        });
      }
    );