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
Environment
Runtime: Browser
Browser Version: Google Chrome: Version 142.0.7444.175 (Official Build) (64-bit)
Reproduction
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\rat the end.Additional context
The
\rending character was a .env parsing mistake.Logs