How to use the parse function from urijs

Find comprehensive JavaScript urijs.parse code examples handpicked from public code repositorys.

3
4
5
6
7
8
9
10
11
12
const s = require('underscore.string');
const URI = require('urijs');

const validModes = ['utf8', 'utf16', 'utf32'];

const { query } = URI.parse(decodeURIComponent(window.location.href));
const MODE = ((left = URI.parseQuery(query).mode) != null ? left : 'utf8').toLowerCase();

if (!Array.from(validModes).includes(MODE)) {
    // Ensure the mode is an actualy encoding
fork icon75
star icon0
watch icon0

+ 9 other calls in file

85
86
87
88
89
90
91
92
93
/*  find a particular route for an HTTP request  */
const findRoute = (req) => {
    let route  = null

    /*  determine request parameters  */
    const url    = URI.parse(req.url)
    const host   = typeof req.headers.host === "string" ? req.headers.host : undefined
    const path   = url.path
    const protos = (req.headers["sec-websocket-protocol"] || "").split(/, */)
fork icon9
star icon54
watch icon3

316
317
318
319
320
321
322
323
324
325
  return callBackPath;
}
try {
  if (credentials.appUrls) {
    const appUrlsJson = JSON.parse(credentials.appUrls);
    let parsedUrl = urijs.parse(appUrlsJson.getDependencies);
    callBackPath.getDependenciesPath = parsedUrl.path;
    parsedUrl = urijs.parse(appUrlsJson.onSubscription);
    let index = parsedUrl.path.indexOf('/{tenantId}');
    if (index > 0){
fork icon0
star icon0
watch icon1

+ 3 other calls in file

379
380
381
382
383
384
385
386
387
388
389
    return fullPath + ' is not a file';
  }
}


function validateAbsoluteUri(uri) {
  const components = URI.parse(uri);
  if (!components.protocol || !components.hostname) {
    return 'URI must be absolute';
  }
  const supportedProtocols = ['http', 'https', 'ws', 'wss'];
fork icon0
star icon0
watch icon1

+ 2 other calls in file

75
76
77
78
79
80
81
82
83
84
  let toCutOut = req.url.length;
  const parsedUrl = urijs.parse(req.url);
  if (req.headers['x-forwarded-path'].indexOf(loginCallback) > -1 && parsedUrl.query) {
    toCutOut = loginCallback.length;
  }
  const parsedXForwardedPath = urijs.parse(req.headers['x-forwarded-path']);
  proxyPrefix = parsedXForwardedPath.path.substr(0, parsedXForwardedPath.path.length - toCutOut +
    (req.url[0] === '/' ? 1 : 0));
}
return urlUtils.join(appRouterUrl + proxyPrefix, loginCallback);
fork icon0
star icon0
watch icon1

12
13
14
15
16
17
18
19
20
21
 * If there is a redirect parameter in the query string, redirect to that page.
 * Otherwise, if there is a UF-Redirect header, redirect to that page.
 * Otherwise, redirect to the home page.
 */
function redirectOnLogin(jqXHR) {
    var components = URI.parse(window.location.href);
    var query = URI.parseQuery(components['query']);

    if (query && query['redirect']) {
        // Strip leading slashes from redirect strings           
fork icon0
star icon0
watch icon0