Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hlx-util

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hlx-util - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

2

package.json
{
"name": "hlx-util",
"version": "0.0.4",
"version": "0.0.5",
"description": "A library to preserve functions commonly used in hlxjs project",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -86,19 +86,17 @@ const {URL} = require('url');

function buildLocalPathFromUrl(url) {
function buildUrlObj(url, base) {
const obj = tryCatch(
() => new URL(url),
() => new URL(url, base),
() => null
);
if (!obj) {
return '';
if (obj) {
obj.search = '';
obj.hash = '';
if (obj.hostname && !obj.pathname.startsWith(obj.hostname, 1)) {
obj.pathname = path.join('/', obj.hostname, obj.pathname);
}
}
obj.search = '';
obj.hash = '';
if (obj.protocol === 'file:') {
return obj.pathname;
}
return path.join('/', obj.hostname, obj.pathname);
return obj;
}

@@ -116,2 +114,3 @@

let localPath;
let obj;
if (path.isAbsolute(uri)) {

@@ -122,11 +121,12 @@ localPath = path.join(outputDir, uri);

}
localPath = buildLocalPathFromUrl(uri);
if (localPath) {
localPath = buildAbsolutePath(localPath, '/', inputDir, outputDir);
obj = buildUrlObj(uri);
if (obj) {
localPath = buildAbsolutePath(obj.pathname, '/', inputDir, outputDir);
print(`\tFrom absolute url to localPath: ${localPath}`);
return localPath;
}
const basePath = buildLocalPathFromUrl(parentUri);
if (basePath) {
localPath = buildAbsolutePath(uri, basePath, inputDir, outputDir);
obj = buildUrlObj(parentUri);
if (obj) {
obj = buildUrlObj(uri, obj.href);
localPath = buildAbsolutePath(obj.pathname, '/', inputDir, outputDir);
print(`\tFrom relative url to localPath: ${localPath}`);

@@ -149,4 +149,4 @@ return localPath;

mkdirP,
buildLocalPathFromUrl,
buildUrlObj,
buildLocalPath
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc