-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fixed an error that ignored baseURL #6
base: master
Are you sure you want to change the base?
Conversation
Hi, thank you for the PR, I'll take a look as soon as I can |
@Tibing We need to make a release with baseURL enabled ASAP, can you take a look at this PR? |
Hi, sorry for the delayed response! Could you please provide a bit more detail about the refactoring you're doing here?
|
const lowercasedUrl = config.url.toLowerCase(); | ||
const lowercasedBaseURL = config.baseURL?.toLowerCase(); | ||
|
||
let url:URL; | ||
if (lowercasedUrl.startsWith('http:') || lowercasedUrl.startsWith('https:')) { | ||
// config.url has a higher priority than config.baseURL | ||
url = new URL(config.url); | ||
} else if (config.baseURL && (lowercasedBaseURL.startsWith('http:') || lowercasedBaseURL.startsWith('https:'))) { | ||
url = new URL(config.baseURL + config.url); | ||
} else { | ||
// failed to find a valid url | ||
throw new Error('Invalid URL: ' + config.url + ' or baseURL: ' + config.baseURL); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic should reside in a separate method or something like that
const lowercasedUrl = config.url.toLowerCase(); | ||
const lowercasedBaseURL = config.baseURL?.toLowerCase(); | ||
|
||
let url:URL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let url:URL; | |
let url: URL; |
url = new URL(config.baseURL + config.url); | ||
} else { | ||
// failed to find a valid url | ||
throw new Error('Invalid URL: ' + config.url + ' or baseURL: ' + config.baseURL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method is not intended to throw an error, it should return false
http2 not supported
Hey @Tibing
I found your library very useful, but has a small issue when axios is configured to use
baseURL
. Please take a look at this PR.Best regards,
Tonny