-
Notifications
You must be signed in to change notification settings - Fork 25
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
fix: Remove trailing slash from url for extra cases #95
Conversation
31886b0
to
f887677
Compare
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.
Looks good but tests are failing so I'm gonna wait to approve until that's solved.
Also, I think it would be good to add a test for setServiceUrl
using a string that ends in a slash, just for completeness.
781bd07
to
732414c
Compare
732414c
to
d6bdf7a
Compare
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.
Looks good! 👍
## [2.4.1](v2.4.0...v2.4.1) (2020-05-14) ### Bug Fixes * Remove trailing slash from url for extra cases ([#95](#95)) ([bcaa168](bcaa168))
🎉 This PR is included in version 2.4.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@@ -141,7 +141,9 @@ export class BaseService { | |||
* @param {string} url The base URL for the service. | |||
*/ | |||
public setServiceUrl(url: string): void { | |||
this.baseOptions.serviceUrl = url; | |||
if (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.
Given a parameter type of just string
, this if statement would be superfluous. Should the type be changed to url?: string
or the if statement removed?
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.
Yeah I think that's a fair point, the if
statement probably doesn't need to be there. Or should be stricter and ensure that it's actually a string. In the JS case (which we think is most of our users), the type or requiredness isn't actually enforced. And stripTrailingSlash
uses the .replace()
method so it will throw a TypeError if url
isn't a string.
I agree that the if
statement as is isn't really that useful
Covered extra cases where trailing slash was not being removed when making a request.
Checklist
npm test
passes (tip:npm run lint-fix
can correct most style issues)