
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
url-value-parser
Advanced tools
A helper ES6 class letting you extract values from URL paths, leaving the other parts untouched.
It uses an internal class ValueDetector determining
what is a value and what is not. By default the following
path chunks are considered values:
You can customize all of the logic by providing options, overriding methods or providing your own value detector. See the source - it's easy, i promise.
const UrlValueParser = require('url-value-parser');
const parser = new UrlValueParser(/* {options} */);
parser.parsePathValues('/some/path/154/userId/ABC363AFE2');
/*
here the values would be 154 and ABC363AFE2
thus it returns:
{
chunks: ['some', 'path', '154', 'userId', 'ABC363AFE2'],
valueIndexes: [2, 5]
}
*/
parser.replacePathValues('/some/path/154/userId/ABC363AFE2', '#id');
// returns: /some/path/#id/userId/#id
If strings are provided in an array to replaceMasks and extraMasks, then they're automatically converted into RegExp
Example:
const parser = new UrlValueParser({
minHexLength: 4,
extraMasks: [
/^z_.*$/,
'^[0-9]+\\.[0-9]+$'
]
});
The query-string package is used to parse and stringify URL query strings. It focuses on handling query parameters rather than the entire URL structure. Compared to url-value-parser, it is more specialized in dealing with query strings and offers utilities for manipulating them.
The url-parse package provides a way to parse URLs into their components (protocol, hostname, port, pathname, query, etc.). It offers a more comprehensive breakdown of the URL structure compared to url-value-parser, which focuses on extracting dynamic values and parameters.
The path-to-regexp package is used to convert paths to regular expressions and extract parameters from them. It is similar to url-value-parser in that it can extract dynamic values from paths, but it is more focused on path matching and less on parsing the entire URL.
FAQs
extracts and replaces values and IDs in URLs
We found that url-value-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.

Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.

Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.