diff --git a/scripts/utils.ts b/scripts/utils.ts index 27b76471af..e5a17110db 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -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, '+') } diff --git a/tests/__data__/input/playlist_normalize/reserved_escapes.m3u b/tests/__data__/input/playlist_normalize/reserved_escapes.m3u index 592ffd05b6..3e854af934 100644 --- a/tests/__data__/input/playlist_normalize/reserved_escapes.m3u +++ b/tests/__data__/input/playlist_normalize/reserved_escapes.m3u @@ -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 diff --git a/tests/commands/playlist/format.test.ts b/tests/commands/playlist/format.test.ts index c3f9b0b825..a7e4165dca 100644 --- a/tests/commands/playlist/format.test.ts +++ b/tests/commands/playlist/format.test.ts @@ -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' + ) }) })