parseHash -> parseLocationHash

This commit is contained in:
jaredvu 2024-02-16 14:27:49 -08:00
parent 25d8ac6593
commit dd1ccac706
No known key found for this signature in database
GPG Key ID: B9FE2F3F0A5D523C
3 changed files with 7 additions and 7 deletions

View File

@ -35,7 +35,7 @@ import { NotificationsToastArea } from '@/layout/NotificationsToastArea';
import { DialogManager } from '@/layout/DialogManager';
import { GlobalCommandDialog } from '@/views/dialogs/GlobalCommandDialog';
import { parseHash } from '@/lib/urlUtils';
import { parseLocationHash } from '@/lib/urlUtils';
import { config } from '@/lib/wagmi';
import { breakpoints } from '@/styles';
@ -75,7 +75,7 @@ const Content = () => {
if (location.hash === '') {
return '';
}
return parseHash(location.hash);
return parseLocationHash(location.hash);
}, [location.hash]);
return (

View File

@ -1,14 +1,14 @@
import { describe, expect, it } from 'vitest';
import { parseHash } from '@/lib/urlUtils';
import { parseLocationHash } from '@/lib/urlUtils';
describe('parseHash', () => {
describe('parseLocationHash', () => {
it('returns the path separated from hash', () => {
const hash = '#/markets';
expect(parseHash(hash)).toEqual('/markets');
expect(parseLocationHash(hash)).toEqual('/markets');
});
it('returns the path and query string separated from hash', () => {
const hash = '#/markets?displayinitializingmarkets=true';
expect(parseHash(hash)).toEqual('/markets?displayinitializingmarkets=true');
expect(parseLocationHash(hash)).toEqual('/markets?displayinitializingmarkets=true');
});
});

View File

@ -2,7 +2,7 @@
* @param hash location.hash
* @returns path and query string if hash parameter is not empty
*/
export const parseHash = (hash: string) => {
export const parseLocationHash = (hash: string) => {
if (!hash || hash.length === 0) return '';
// Remove '#' and split by '?'