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.
@jridgewell/resolve-uri
Advanced tools
The @jridgewell/resolve-uri package is designed to resolve URIs in a consistent and reliable manner. It provides functionality for resolving relative URIs against a base URI, similar to how web browsers resolve relative links. This can be particularly useful in web development and applications that need to handle various URI manipulations.
Resolving relative URIs
This feature allows the resolution of a relative URI against a base URI, effectively calculating the absolute URI. It's particularly useful for web applications that need to dynamically resolve links or resources.
"const resolveUri = require('@jridgewell/resolve-uri');\nconst baseUri = 'http://example.com/dir/page.html';\nconst relativeUri = '../image.png';\nconst resolvedUri = resolveUri(relativeUri, baseUri);\nconsole.log(resolvedUri); // Outputs: 'http://example.com/image.png'"
The url-resolve package offers similar functionality for resolving URLs. It provides a simple API for combining a base URL with a relative path to form a complete URL. Compared to @jridgewell/resolve-uri, it might offer a simpler interface but lacks some of the advanced resolution capabilities and optimizations present in @jridgewell/resolve-uri.
resolve-url is another npm package that provides URL resolution capabilities. It is designed to resolve URLs in a manner similar to web browsers, handling various edge cases and relative path scenarios. While it shares similar goals with @jridgewell/resolve-uri, the implementation details and specific features may vary, offering different performance characteristics or API nuances.
Resolve a URI relative to an optional base URI
Resolve any combination of absolute URIs, protocol-realtive URIs, absolute paths, or relative paths.
npm install @jridgewell/resolve-uri
function resolve(input: string, base?: string): string;
import resolve from '@jridgewell/resolve-uri';
resolve('foo', 'https://example.com'); // => 'https://example.com/foo'
Input | Base | Resolution | Explanation |
---|---|---|---|
https://example.com | any | https://example.com/ | Input is normalized only |
//example.com | https://base.com/ | https://example.com/ | Input inherits the base's protocol |
//example.com | rest | //example.com/ | Input is normalized only |
/example | https://base.com/ | https://base.com/example | Input inherits the base's origin |
/example | //base.com/ | //base.com/example | Input inherits the base's host and remains protocol relative |
/example | rest | /example | Input is normalized only |
example | https://base.com/dir/ | https://base.com/dir/example | Input is joined with the base |
example | https://base.com/file | https://base.com/example | Input is joined with the base without its file |
example | //base.com/dir/ | //base.com/dir/example | Input is joined with the base's last directory |
example | //base.com/file | //base.com/example | Input is joined with the base without its file |
example | /base/dir/ | /base/dir/example | Input is joined with the base's last directory |
example | /base/file | /base/example | Input is joined with the base without its file |
example | base/dir/ | base/dir/example | Input is joined with the base's last directory |
example | base/file | base/example | Input is joined with the base without its file |
FAQs
Resolve a URI relative to an optional base URI
The npm package @jridgewell/resolve-uri receives a total of 37,953,546 weekly downloads. As such, @jridgewell/resolve-uri popularity was classified as popular.
We found that @jridgewell/resolve-uri demonstrated a healthy version release cadence and project activity because the last version was released less than 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.