Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Must create a instance o URL first #1968

Open
rodrigoreis opened this issue Feb 4, 2024 · 0 comments
Open

Must create a instance o URL first #1968

rodrigoreis opened this issue Feb 4, 2024 · 0 comments

Comments

@rodrigoreis
Copy link

const urlParams = new URLSearchParams(url);

Fuction getStartTimeFromUrl from src/utils/urlParser.ts will not work with URLString. An instance o URL must be created first and then URLSearchParams can be created using the property search from URL instance. This is necessary because the URLSearchParams constructor does not analyze complete URLs.

from:

export function getStartTimeFromUrl(url: string): number {
    const urlParams = new URLSearchParams(url);
    const time = urlParams?.get('t') || urlParams?.get('time_continue');

    return urlTimeToSeconds(time);
}

to:

export function getStartTimeFromUrl(url: string): number {
    const urlParams = new URLSearchParams(new URL(url).search);
    const time = urlParams?.get('t') || urlParams?.get('time_continue');

    return urlTimeToSeconds(time);
}

I hope I've helped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant