mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 19:46:16 -08:00
fix(downloads): normalize fragments before queries
This commit is contained in:
1 parent
5fd9b2eb35
commit
e8e2a31312
2 files changed
+25
-5
No files matched your search
@@ -64,9 +64,7 @@ describe('workspace-shell-route.utils', () => {
|
||||
|
||||
it('disables collection shell state for focused download details', () => {
|
||||
expect(
|
||||
parseWorkspaceShellRoute(
|
||||
'/workspace/downloads/42?query=matrix#technical-details'
|
||||
)
|
||||
parseWorkspaceShellRoute('/workspace/downloads/42?q=x#details')
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
kind: 'downloads',
|
||||
@@ -111,6 +109,28 @@ describe('workspace-shell-route.utils', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
'keeps Xtream query state before a fragment',
|
||||
'/workspace/xtreams/pl-1/favorites?scope=all#details',
|
||||
true,
|
||||
],
|
||||
[
|
||||
'keeps Stalker query state before a fragment',
|
||||
'/workspace/stalker/pl-1/favorites?scope=all#details',
|
||||
true,
|
||||
],
|
||||
[
|
||||
'ignores query-like text inside a fragment',
|
||||
'/workspace/xtreams/pl-1/favorites#details?scope=all',
|
||||
false,
|
||||
],
|
||||
])('%s', (_name, url, expectedAllScope) => {
|
||||
expect(parseWorkspaceShellRoute(url).isPortalFavoritesAllScope).toBe(
|
||||
expectedAllScope
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps manager shell state outside exact focused download routes', () => {
|
||||
expect(parseWorkspaceShellRoute('/workspace/downloads/')).toEqual(
|
||||
expect.objectContaining({
|
||||
|
||||
@@ -86,8 +86,8 @@ function normalizePath(url: string): {
|
||||
segments: string[];
|
||||
queryParams: URLSearchParams;
|
||||
} {
|
||||
const [pathWithFragment, query = ''] = url.split('?');
|
||||
const [path] = pathWithFragment.split('#');
|
||||
const [urlWithoutFragment] = url.split('#');
|
||||
const [path, query = ''] = urlWithoutFragment.split('?');
|
||||
return {
|
||||
segments: path.split('/').filter(Boolean),
|
||||
queryParams: new URLSearchParams(query),
|
||||
|
||||
Reference in new issue
Block a user