Description
Bug Description
The parseOrigin function in the undici library throws an InvalidArgumentError when a URL contains a path, query, or fragment. This behavior makes it difficult to use the library with valid URLs like https://api.domain.com/elastic/. that's because of an if condition in the function.
This strict validation seems unnecessary for some use cases, and there should be a way to relax it.
Reproducible By
Modify parseOrigin to allow URLs with paths.
Alternatively, provide an option to bypass this validation.
navigate to \node_modules\undici\lib\core\util.js
`function parseOrigin (url) {
url = parseURL(url)
if (url.pathname !== '/' || url.search || url.hash) {
throw new InvalidArgumentError('invalid url')
}
return url
}will be
function parseOrigin (url) {
url = parseURL(url)
if (url.search || url.hash) {
throw new InvalidArgumentError('invalid url')
}
return url
}`
or sothisng selse semeler to that just without the exception of a "/"
Expected Behavior
Logs & Screenshots
Node.js version: v18.20.4
Undici version: X.X.X
Activity