Skip to content

Got doesn't throw on leading slashes #1057

@szmarczak

Description

@szmarczak

As per the readme:

Note: Leading slashes in input are disallowed when using this option to enforce consistency and avoid confusion. For example, when the prefix URL is https://example.com/foo and the input is /bar, there's ambiguity whether the resulting URL would become https://example.com/foo/bar or https://example.com/bar. The latter is used by browsers.

But it does not throw:

if (is.string(options.url)) {
options.url = (options.prefixUrl as string) + options.url;
options.url = options.url.replace(/^unix:/, 'http://$&');
if (options.searchParams || options.search) {
options.url = options.url.split('?')[0];
}
// @ts-ignore URL is not URL
options.url = optionsToUrl({
origin: options.url,
...options
});
} else if (!is.urlInstance(options.url)) {
// @ts-ignore URL is not URL
options.url = optionsToUrl({origin: options.prefixUrl as string, ...options});
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething does not work as it shouldregressionSomething does not work anymore✭ help wanted ✭

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions