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

hlx-url-rewriter

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hlx-url-rewriter - npm Package Compare versions

Comparing version 0.0.22 to 0.0.23

35

default.js

@@ -64,6 +64,27 @@ const path = require('path');

function createRelativeFunc(fromPath) {
return pathname => path.relative(path.dirname(fromPath), pathname);
function createPath(url, rootPath) {
let absolutePath;
if (url.protocol === 'file:') {
if (url.pathname.startsWith(rootPath)) {
absolutePath = url.pathname;
} else {
absolutePath = path.join(rootPath, url.pathname);
}
} else {
absolutePath = path.join('/', url.hostname, url.pathname);
}
print(`\tcreatePath: ${url.href} => ${absolutePath}`);
return absolutePath;
}
function createRelativePath(fromUrl, toUrl) {
const {rootPath = '/'} = defaultFunc.options;
const fromPath = createPath(fromUrl, rootPath);
let toPath = createPath(toUrl, rootPath);
if (fromUrl.protocol === 'file:' && toUrl.protocol !== 'file:') {
toPath = path.join(rootPath, toPath);
}
return path.relative(path.dirname(fromPath), toPath);
}
function rewrite(uri, base) {

@@ -81,11 +102,3 @@ const {rootPath = '/'} = defaultFunc.options;

}
const relativeToPlaylist = createRelativeFunc(playlistUrl.pathname);
let result;
if (url.protocol === playlistUrl.protocol && url.hostname === playlistUrl.hostname) {
print('\tpattern-A');
result = relativeToPlaylist(url.pathname);
} else {
print('\tpattern-B');
result = relativeToPlaylist(path.join(playlistUrl.protocol === 'file:' ? rootPath : '/', url.hostname, url.pathname));
}
const result = createRelativePath(playlistUrl, url);
print(`\t>>> "${result}"`);

@@ -92,0 +105,0 @@ return `${result}${url.search}${url.hash}`;

{
"name": "hlx-url-rewriter",
"version": "0.0.22",
"version": "0.0.23",
"description": "A transform stream to modify URLs contained in HLS playlists",

@@ -60,3 +60,3 @@ "main": "index.js",

"debug": "^4.1.1",
"hlx-util": "0.0.8"
"hlx-util": "0.0.9"
},

@@ -63,0 +63,0 @@ "devDependencies": {

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