mirror of
https://github.com/iptv-org/iptv.git
synced 2026-11-16 13:28:01 +02:00
fix: keep encoded query delimiters when playlist:format normalizes links
normalize-url sorts the query parameters by default and then runs decodeURIComponent on the whole query, so %26, %3D, %3F and %2B come back as &, =, ? and +. A link that passes another URL as a parameter loses part of it to the outer query, and %2B turns into a space. The order of the parameters is now left as is.
This commit is contained in:
+1
-1
@@ -41,7 +41,7 @@ export function isURI(string: string): boolean {
|
||||
export function normalizeURL(url: string): string {
|
||||
let normalized: string
|
||||
try {
|
||||
normalized = normalizeUrl(url, { stripWWW: false })
|
||||
normalized = normalizeUrl(url, { stripWWW: false, sortQueryParameters: false })
|
||||
} catch {
|
||||
return url.replace(/\s/g, '+')
|
||||
}
|
||||
|
||||
@@ -5,3 +5,5 @@ http://example.com/TVP%20Wilno%20HD/index.m3u8
|
||||
http://example.com/a%2Fb/index.m3u8
|
||||
#EXTINF:-1 tvg-id="",Example Query Hash (720p)
|
||||
http://example.com/index.m3u8?id=1%232
|
||||
#EXTINF:-1 tvg-id="",Example Query Nested URL (720p)
|
||||
http://example.com/index.m3u8?name=TV%2B&url=http%3A%2F%2Fexample.org%2Fa.m3u8%3Fk%3D1%26exp%3D2
|
||||
|
||||
@@ -67,6 +67,9 @@ describe('playlist:format', () => {
|
||||
expect(output).toContain('http://example.com/TVP%20Wilno%20HD/index.m3u8')
|
||||
expect(output).toContain('http://example.com/a%2Fb/index.m3u8')
|
||||
expect(output).toContain('http://example.com/index.m3u8?id=1%232')
|
||||
expect(output).toContain(
|
||||
'http://example.com/index.m3u8?name=TV%2B&url=http%3A%2F%2Fexample.org%2Fa.m3u8%3Fk%3D1%26exp%3D2'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user