Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@types/url-parse
Advanced tools
TypeScript definitions for url-parse
@types/url-parse provides TypeScript type definitions for the url-parse library, which is used to parse, manipulate, and build URLs in JavaScript.
Parsing URLs
This feature allows you to parse a URL into its components such as protocol, hostname, port, pathname, query, and hash.
const URLParse = require('url-parse');
const url = new URLParse('https://example.com:8080/pathname/?search=test#hash');
console.log(url.protocol); // 'https:'
console.log(url.hostname); // 'example.com'
console.log(url.port); // '8080'
console.log(url.pathname); // '/pathname/'
console.log(url.query); // '?search=test'
console.log(url.hash); // '#hash'
Modifying URLs
This feature allows you to modify different parts of a URL and then convert it back to a string.
const URLParse = require('url-parse');
let url = new URLParse('https://example.com/pathname/?search=test#hash');
url.set('protocol', 'http');
url.set('hostname', 'example.org');
url.set('port', '3000');
console.log(url.toString()); // 'http://example.org:3000/pathname/?search=test#hash'
Query String Parsing
This feature allows you to parse the query string into an object for easier manipulation.
const URLParse = require('url-parse');
const url = new URLParse('https://example.com/pathname/?search=test&foo=bar', true);
console.log(url.query); // { search: 'test', foo: 'bar' }
Building URLs
This feature allows you to build a URL by setting its different components and then converting it back to a string.
const URLParse = require('url-parse');
const url = new URLParse('https://example.com');
url.set('pathname', '/newpath');
url.set('query', { search: 'newtest', foo: 'newbar' });
console.log(url.toString()); // 'https://example.com/newpath?search=newtest&foo=newbar'
The 'url' package is a core Node.js module that provides utilities for URL resolution and parsing. It is similar to url-parse but is built into Node.js and may not have as many features for URL manipulation.
The 'query-string' package focuses on parsing and stringifying URL query strings. It provides a more specialized set of functionalities compared to url-parse, which handles the entire URL.
The 'whatwg-url' package is a full implementation of the WHATWG URL Standard. It provides a more standards-compliant way to parse and manipulate URLs compared to url-parse.
npm install --save @types/url-parse
This package contains type definitions for url-parse (https://github.com/unshiftio/url-parse).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/url-parse.
These definitions were written by Hari Sivaramakrishnan, Dmitry Dushkin, David Golightly, and Kit Song.
FAQs
TypeScript definitions for url-parse
We found that @types/url-parse 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.