/*
@param {Object} pagaData
@prop {Array} pathValues: values used to replace url placeholder
@prop {String} querystring: value of the querystring
14072
function (pageData) {
    var pageUrl = this.url;
    if (pageData && pageData.pathValues && pageData.pathValues.length > 0){
      pageUrl.match(/\${\w+}/gi).forEach(function(placeholder,i){
        pageUrl = pageUrl.replace(placeholder, pageData.pathValues[i]);
      });
    }

    var hasProtocol = !!(pageUrl || '').match('^https?:\/\/');
    var urlObj = url.parse(hasProtocol ? pageUrl : config.baseUrl + pageUrl);

    if (pageData && pageData.querystring) {
      urlObj.search = pageData.querystring;
    }

    return session.getDriver().get(url.format(urlObj))
    .then(function() {
      if (typeof this.onLoad === 'function') {
        return session.execute(this.onLoad);
      }
    }.bind(this));
  }
221943
function querystring(query) {
  var parser = /([^=?&]+)=?([^&]*)/g
    , result = {}
    , part;

  while (part = parser.exec(query)) {
    var key = decode(part[1])
      , value = decode(part[2]);

    //
    // Prevent overriding of existing properties. This ensures that build-in
    // methods like `toString` or __proto__ are not overriden by malicious
    // querystrings.
    //
    if (key in result) continue;
    result[key] = value;
  }

  return result;
}
443054
function supportsSvgPathArgument(window) {
  const canvas = window.document.createElement('canvas');
  const g = canvas.getContext('2d');
  const p = new window.Path2D('M0 0 L1 1');
  g.strokeStyle = 'red';
  g.lineWidth = 1;
  g.stroke(p);
  const imgData = g.getImageData(0, 0, 1, 1);
  return imgData.data[0] === 255; // Check if pixel is red
}
1361889
function sgTrackingUrlMapper(url, data) {
  // In our development system urls start with /php/shopgate/ always
  const developmentPath = '/php/shopgate/';
  const appRegex = /sg_app_resources\/[0-9]*\//;

  // Build regex that will remove all blacklisted paramters
  let regex = '';
  urlParameterBlacklist.forEach((entry) => {
    regex += `((\\?|^){0,1}(${entry}=.*?(&|$)))`;
    regex += '|';
  });
  const params = url.indexOf('?') !== -1 ? url.split('?')[1] : '';
  let urlParams = params.replace(new RegExp(regex, 'g'), '');
  urlParams = urlParams === '' ? '' : `?${urlParams.replace(/&$/, '')}`;

  // Get rid of hash and app urls
  let urlPath = url.split('?')[0].split('#')[0].replace(appRegex, '');

  // Get path from url
  if (url.indexOf(developmentPath) !== -1) {
    urlPath = urlPath.substring(urlPath.indexOf(developmentPath) + developmentPath.length);
  } else if (urlPath.indexOf('http') !== -1) {
    urlPath = urlPath.substring(urlPath.indexOf('/', urlPath.indexOf('//') + 2) + 1);
  } else {
    urlPath = urlPath.substring(1);
  }

  // Get action from path
  const action = urlPath.substring(
    0,
    ((urlPath.indexOf('/') !== -1) ? (urlPath.indexOf('/')) : undefined)
  );

  // If no mapping function is available for the action, continue
  if (typeof mapping[action] === 'undefined') {
    return {
      public: urlPath + urlParams,
      private: action,
    };
  }

  // Call mapping function and return its result
  const pathWithoutAction = urlPath.substring(action.length + 1);
  let pathWithoutActionArray = [];

  if (pathWithoutAction.length !== 0) {
    pathWithoutActionArray = pathWithoutAction.split('/');
  }

  const mappedUrls = mapping[action](pathWithoutActionArray, data || {});

  if (Array.isArray(mappedUrls)) {
    return {
      public: mappedUrls[1] + urlParams,
      private: mappedUrls[0],
    };
  }

  return {
    public: mappedUrls + urlParams,
    private: mappedUrls,
  };
}
983792
function encodeLink(path, value, attrs) {
    var allowedAttrs = [ 'pmin', 'pmax', 'gt', 'lt', 'st' ],
        pathType = cutils.getPathDateType(path),
        pathArray = cutils.getPathArray(path),
        oid = pathArray[0],
        attrsPayload = '',
        linkFormat = '';

    _.forEach(attrs, function (val, key) {
        if (_.includes(allowedAttrs, key) && _.isNumber(val))
            attrsPayload = attrsPayload + ';' + key + '=' + val;   // ';pmin=0;pmax=60'
    });

    path = cutils.getNumPath(path);
    linkFormat = '<' + path + '>' + attrsPayload + ',';

    switch (pathType) {
        case 'object':         // obj
            _.forEach(value, function (iobj, iid) {
                _.forEach(iobj, function (val, rid) {
                    linkFormat = linkFormat + '<' + path + '/' + iid + '/' + cutils.ridNumber(oid, rid) + '>' + ',';
                });
            });
            break;

        case 'instance':         // inst
            _.forEach(value, function (val, rid) {
                linkFormat = linkFormat + '<' + path + '/' + cutils.ridNumber(oid, rid) + '>' + ',';
            });
            break;

        case 'resource':         // resrc
            break;

        default:
            break;
    }

    if (linkFormat[linkFormat.length-1] === ',')
        linkFormat = linkFormat.slice(0, linkFormat.length - 1);

    return linkFormat;
}
1068388
function compare(pathData,opts={}) {
	var polys = svgPathToPolygons(pathData,opts);
	var minX=Infinity, maxX=-Infinity, minY=Infinity, maxY=-Infinity;
	polys.forEach(poly => {
		poly.forEach(pt => {
			if (pt[0]<minX) minX=pt[0];
			if (pt[1]<minY) minY=pt[1];
			if (pt[0]>maxX) maxX=pt[0];
			if (pt[1]>maxY) maxY=pt[1];
		});
	});
	let dx=maxX-minX, dy=maxY-minY;
	console.log(`
<svg xmlns="http://www.w3.org/2000/svg" width="${dx}px" height="${dy}px" viewBox="${minX} ${minY} ${dx*2} ${dy}">
<style>path,polygon,polyline { fill-opacity:0.2; stroke:black }</style>
<path d="${pathData}"/>
<g transform="translate(${dx},0)">
${polys.map(poly => `  <${poly.closed ? 'polygon' : 'polyline'} points="${poly.join(' ')}"/>`).join("\n")}
</g>
</svg>
	`.trim());
}
707331
function parsePathParams (req, res, next) {
    if (util.isSwaggerRequest(req)) {
      req.pathParams = {};

      if (req.swagger.pathName.indexOf("{") >= 0) {
        // Convert the Swagger path to a RegExp
        let paramNames = [];
        let pathPattern = req.swagger.pathName.replace(util.swaggerParamRegExp, (match, paramName) => {
          paramNames.push(paramName);
          return "([^\/]+)";
        });

        // Exec the RegExp to get the path param values from the URL
        let values = new RegExp(pathPattern + "\/?$", "i").exec(req.path);

        // Parse each path param
        for (let i = 1; i < values.length; i++) {
          let paramName = paramNames[i - 1];
          let paramValue = decodeURIComponent(values[i]);
          let param = _.find(req.swagger.params, { in: "path", name: paramName });

          util.debug('    Parsing the "%s" path parameter', paramName);
          req.pathParams[paramName] = paramParser.parseParameter(param, paramValue, param);
        }
      }
    }

    next();
  }
776852
protected static final QueryMap parseApiRequestQueryParams(String queryString) {
        QueryMap rval = new QueryMap();

        if (queryString != null) {
            try {
                String[] pairSplit = queryString.split("&"); //$NON-NLS-1$
                for (String paramPair : pairSplit) {
                    int idx = paramPair.indexOf("="); //$NON-NLS-1$
                    String key, value;
                    if (idx != -1) {
                        key =  URLDecoder.decode(paramPair.substring(0, idx), "UTF-8"); //$NON-NLS-1$
                        value = URLDecoder.decode(paramPair.substring(idx + 1), "UTF-8"); //$NON-NLS-1$
                    } else {
                        key = URLDecoder.decode(paramPair, "UTF-8"); //$NON-NLS-1$
                        value = null;
                    }
                    rval.add(key,  value);
                }
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            }

        }

        return rval;
    }
1091066
function getValue(data, path) {
  if (typeof data !== 'object' || data === null) {
    return void 0;
  } else if (path.length === 1) {
    return data[path[0]];
  }
  return getValue(data[path[0]], path.slice(1));
}
130966
protected Object getDataValue(Trace trace, Node node, Direction direction, Map<String, ?> headers,
            Object[] values) {
        if (source == DataSource.Content) {
            return values[index];
        } else if (source == DataSource.Header) {
            return headers.get(key);
        }
        return null;
    }
133988
@SuppressWarnings("unchecked")
    public static MultiValueMap<String, String> getParamsFromQueryString(String queryString) {
        MultiValueMap queryParams = new LinkedMultiValueMap<>();

        if (StringUtils.isNotEmpty(queryString)) {
            String[] params = queryString.split("&");
            for (String param : params) {
                String[] splitParam = param.split("=");
                String paramName = splitParam[0];
                String paramValue = splitParam[1];

                queryParams.add(paramName, paramValue);
            }
        }

        return queryParams;
    }
1042017
function nodePathStringByURL( $params )
    {
        $pathString = '';

        $node = $this->nodeByUrl( $params );

        if( is_object( $node ) )
        {
            $pathString = $node->attribute( 'path_string' );
        }

        return $pathString;
    }
243319
function parse(arg)
{
  try{
    var url = urllib.parse(arg, true);
  }catch(E){
    return false;
  }

  // paths is always an array
  if(!url.query.paths) url.query.paths = [];
  if(!Array.isArray(url.query.paths)) url.query.paths = [url.query.paths];
  
  // parse any paths
  url.paths = [];
  url.query.paths.forEach(function(epath){
    try{
      var path = JSON.parse(hashname.base32.decode(epath));
      if(typeof path == 'object' && typeof path.type == 'string') url.paths.push(path);
    }catch(E){};
  });

  // parse any csid keys
  url.keys = {};
  Object.keys(url.query).forEach(function(id){
    if(id.length != 4 || id.substr(0,2) != 'cs') return;
    url.keys[id.substr(2)] = url.query[id];
  });
  
  // parse any fragment
  if(url.hash) url.fragment = hashname.base32.decode(url.hash.substr(1));
  
  // add formatting wrapper
  url.encode = function()
  {
    // delete these to force lib to make new
    delete url.search;
    delete url.href;
    if(url.query.paths.length == 0) delete url.query.paths; // dumb node bug
    return urllib.format(url);
  }
  
  return url;
}
622979
function (jsonObject, path, force, value) {
  if (!path) {
    return;
  }
  var newValue, obj;
  obj = jsonObject || {};
  path.trim().split('.').some(function (key, index, array) {
    if (!key && key !== 0) {
      return false;
    }
    newValue = obj[key];
    if (index == array.length - 1) {
      if (value === undefined) {
        value = {};
      }
      obj[key] = value;
      return true;
    }
    if (!newValue && newValue != 0 && index <= (array.length - 1)) {
      if (force) {
        obj[key] = {};
      } else {
        return true;
      }
    }
    obj = obj[key];
  });

  return jsonObject;
}
756228
function pathStrToPathArr(path) {
	path = path.substr(1).split('/').map(part => {
		// De-tokenize '/' characters in path name
		return part.replace(/~1/g, '/');
	});

	// For some reason, path arrays whose only item is an empty string cause errors.
	// In this case, we replace the path with an empty array, which seems to be fine.
	if (path.length === 1 && path[0] === '') {
		path = [];
	}

	return path;
}
184467
function(request, urlVar, urlVal, params) {

        var matched     = -1
            , _param    = urlVar.match(/\:\w+/g)
            , regex     = null
            , tested    = false;

        if (!_param.length) return false;

        //  if custom path, path rewrite
        if (request.routing.param.path) {
            regex = new RegExp(urlVar, 'g')
            if ( regex.test(request.routing.param.path) ) {
                request.routing.param.path = request.routing.param.path.replace(regex, urlVal);
            }
        }

        //  if custom file, file rewrite
        if (request.routing.param.file) {
            regex = new RegExp(urlVar, 'g')
            if ( regex.test(request.routing.param.file) ) {
                request.routing.param.file = request.routing.param.file.replace(regex, urlVal);
            }
        }

        if (_param.length == 1) {// fast one
            matched =  ( _param.indexOf(urlVar) > -1 ) ? _param.indexOf(urlVar) : false;

            if (matched === false) return matched;
            // filter on method
            if (params.method !== request.method) return false;

            var key = _param[matched].substr(1);
            regex   = params.requirements[key];

            if ( /^\//.test(regex) ) {
                var re      = regex.match(/\/(.*)\//).pop()
                    , flags = regex.replace('/'+ re +'/', '');

                tested = new RegExp(re, flags).test( urlVal )

            } else {
                tested = new RegExp(params.requirements[key]).test( urlVal )
            }

            if (
                typeof(params.param[key]) != 'undefined' &&
                typeof(params.requirements) != 'undefined' &&
                typeof(params.requirements[key]) != 'undefined' &&
                tested
            ) {
                request.params[key] = urlVal;
                return true
            }

        } else { // slow one

            // In order to support rules defined like :
            //      { params.url }  => `/section/:name/page:number`
            //      { request.url } => `/section/plante/page4`
            //
            //      with keys = [ ":name", ":number" ]

            var keys        = _param
                , tplUrl    = params.url
                , url       = request.url
                , values    = {}
                , strVal    = ''
                , started   = false
                , i         = 0;

            for (var c = 0, posLen = url.length; c < posLen; ++c) {
                if (url.charAt(c) == tplUrl.charAt(i) && !started) {
                    ++i
                    continue
                } else if (strVal == '') { // start

                    started = true;
                    strVal += url.charAt(c);
                } else if ( c > (tplUrl.indexOf(keys[0]) + keys[0].length) ) {

                    regex   = params.requirements[keys[0]];
                    urlVal  = strVal.substr(0, strVal.length);

                    if ( /^\//.test(regex) ) {
                        var re      = regex.match(/\/(.*)\//).pop()
                            , flags = regex.replace('/'+ re +'/', '');

                        tested = new RegExp(re, flags).test( urlVal )

                    } else {
                        tested = new RegExp(params.requirements[key]).test( urlVal )
                    }

                    if (tested) {
                        values[ keys[0].substr(1) ] = urlVal
                    } else {
                        return false
                    }

                    strVal =  '';
                    started = false;
                    i = (tplUrl.indexOf(keys[0]) + keys[0].length);
                    c -= 1;

                    keys.splice(0,1)
                } else {
                    strVal += url.charAt(c);
                    ++i
                }

                if (c == posLen - 1 ) {

                    regex   = params.requirements[keys[0]];
                    urlVal  = strVal.substr(0, strVal.length);

                    if ( /^\//.test(regex) ) {
                        var re      = regex.match(/\/(.*)\//).pop()
                            , flags = regex.replace('/'+ re +'/', '');

                        tested = new RegExp(re, flags).test( urlVal )

                    } else {
                        tested = new RegExp(params.requirements[key]).test( urlVal )
                    }

                    if (tested) {
                        values[ keys[0].substr(1) ] = urlVal
                    } else {
                        return false
                    }

                }

            }

            if (values.count() == keys.length) {
                for (var key in values) {
                    request.params[key] = values[key];
                }
                return true
            }

        }

        return false
    }
591931
function decodeDataUrlFromQueryParam(value) {
  if (typeof value !== 'string') {
    return undefined
  }
  const maybeDataUrl = prependPrefix(value, 'data:')
    .replace(/ /g, '+')
    .replace(/\s/g, '')
  return isDataUrl(maybeDataUrl) ? maybeDataUrl : undefined
}