-
Notifications
You must be signed in to change notification settings - Fork 158
Merging URL Components #530
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Environment
Runtime: Browser
Browser Version: Google Chrome: Version 142.0.7444.175 (Official Build) (64-bit)
Reproduction
import { ofetch } from "ofetch";
ofetch('/path', {
baseURL: 'https://example.org/',
query: {
q: 'y',
},
onRequest: [({ request }) => {
console.log(request.toString()); // https://example.org/path?q=y
}]
});
ofetch('/path', {
baseURL: 'https://example.org/\r',
query: {
q: 'y',
},
onRequest: [({ request }) => {
console.log(request.toString()); // https://example.org/?q=y
}]
});Describe the bug
Merging URL components doesn’t work correctly in some scenarios. For example, when the baseURL ends with \r (e.g. 'https://example.org/\r'), ofetch completely skips the path part and only appends the query parameters to the base URL. However, if the request has no query parameters, it still works, even with the \r at the end.
Additional context
The \r ending character was a .env parsing mistake.
Logs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working