hlx-url-rewriter
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -64,8 +64,2 @@ const path = require('path'); | ||
function relativePath(from, to) { | ||
const fromDir = path.dirname(from); | ||
print(`\trelativePath: from="${fromDir}", to="${to}"`); | ||
return path.relative(fromDir, to); | ||
} | ||
function rewrite(uri, base) { | ||
@@ -84,11 +78,14 @@ const {rootPath = '/'} = defaultFunc.options; | ||
let result; | ||
if (playlistUrl && url.protocol === playlistUrl.protocol && url.hostname === playlistUrl.hostname) { | ||
print('\tpattern-a'); | ||
result = relativePath(playlistUrl.pathname, url.pathname); | ||
} else if (playlistUrl && playlistUrl.protocol === 'file:') { | ||
print('\tpattern-b'); | ||
result = relativePath(playlistUrl.pathname, path.join(rootPath, url.hostname, url.pathname)); | ||
if (!playlistUrl) { | ||
print('\tpattern-A'); | ||
result = path.relative(url.protocol === 'file:' ? rootPath : '/', url.pathname); | ||
} else if (url.protocol === playlistUrl.protocol && url.hostname === playlistUrl.hostname) { | ||
print('\tpattern-B'); | ||
result = path.relative(path.dirname(playlistUrl.pathname), url.pathname); | ||
} else if (playlistUrl.protocol === 'file:') { | ||
print('\tpattern-C'); | ||
result = path.relative(path.dirname(playlistUrl.pathname), path.join(rootPath, url.hostname, url.pathname)); | ||
} else { | ||
print('\tpattern-c'); | ||
result = `/${url.hostname}${url.pathname}`; | ||
print('\tpattern-D'); | ||
result = path.join('/', url.hostname, url.pathname); | ||
} | ||
@@ -95,0 +92,0 @@ print(`\t>>> "${result}"`); |
{ | ||
"name": "hlx-url-rewriter", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "A transform stream to modify URLs contained in HLS playlists", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9150
117