Skip to content
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

Merged
merged 1 commit into from
May 14, 2020

Conversation

rmkeezer
Copy link
Contributor

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)
  • tests are included

@rmkeezer rmkeezer requested a review from dpopp07 May 13, 2020 10:52
@rmkeezer rmkeezer force-pushed the trailing_slashes_2 branch 2 times, most recently from 31886b0 to f887677 Compare May 13, 2020 11:07
Copy link
Member

@dpopp07 dpopp07 left a 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.

@rmkeezer rmkeezer force-pushed the trailing_slashes_2 branch 2 times, most recently from 781bd07 to 732414c Compare May 13, 2020 18:15
@rmkeezer rmkeezer force-pushed the trailing_slashes_2 branch from 732414c to d6bdf7a Compare May 13, 2020 18:31
@rmkeezer rmkeezer requested a review from dpopp07 May 13, 2020 18:41
Copy link
Member

@dpopp07 dpopp07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍

@rmkeezer rmkeezer merged commit bcaa168 into master May 14, 2020
ibm-devx-automation pushed a commit that referenced this pull request May 14, 2020
## [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))
@ibm-devx-automation
Copy link

🎉 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) {
Copy link
Contributor

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?

Copy link
Member

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

@padamstx padamstx deleted the trailing_slashes_2 branch November 10, 2020 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants