@warren-bank/hls-proxy 3.4.2 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/hls-proxy/utils.js +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -231,6 +231,8 @@ options:
|
|
|
231
231
|
* conditionally modify the content of .m3u8 files __before__ they are parsed to extract URLs
|
|
232
232
|
* `"redirect": (url) => new_url`
|
|
233
233
|
* conditionally redirect the URLs encountered in .m3u8 files __before__ they are modified to pass through the proxy
|
|
234
|
+
* `"rewrite": (url) => new_url`
|
|
235
|
+
* conditionally rewrite the URLs requested by clients __before__ they are proxied
|
|
234
236
|
* `"prefetch": (url) => boolean`
|
|
235
237
|
* conditionally decide whether to prefetch video segments on a per-URL basis
|
|
236
238
|
* return value must be a strict boolean type (ie: `true` or `false`)
|
package/hls-proxy/utils.js
CHANGED
|
@@ -17,7 +17,7 @@ const base64_decode = function(str) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
const parse_req_url = function(params, req) {
|
|
20
|
-
const {is_secure, host, manifest_extension, segment_extension} = params
|
|
20
|
+
const {is_secure, host, manifest_extension, segment_extension, hooks} = params
|
|
21
21
|
|
|
22
22
|
const result = {redirected_base_url: '', url_type: '', url: '', referer_url: ''}
|
|
23
23
|
|
|
@@ -38,7 +38,11 @@ const parse_req_url = function(params, req) {
|
|
|
38
38
|
|
|
39
39
|
let url, url_lc, index
|
|
40
40
|
|
|
41
|
-
url
|
|
41
|
+
url = base64_decode( decodeURIComponent( matches[2] ) ).trim()
|
|
42
|
+
|
|
43
|
+
if (hooks && (hooks instanceof Object) && hooks.rewrite && (typeof hooks.rewrite === 'function'))
|
|
44
|
+
url = hooks.rewrite(url)
|
|
45
|
+
|
|
42
46
|
url_lc = url.toLowerCase()
|
|
43
47
|
index = url_lc.indexOf('http')
|
|
44
48
|
|
package/package.json
CHANGED