fix: Stop using path.join to create URLs. #1455
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
r? @kamil-stripe @pakrym-stripe
Summary
Stop using
path.join
to create URLs and instead just join them.path.join
is meant for file system paths, and introduces extra surprises. eg. passing.
/..
to a path parameter would update the entire path (path.join('a, '..', 'b' => 'b'
andpath.join('a', '.', 'b') => a/b
). This also eliminates the need for transforming the Windows path separator.Unfortunately because this is part of the public API we can't just do
.join('/')
and call it quits.path.join
transforms//
to/
, and users can technically pass in values which lead to//
since we don't document the expectations. So to be safe, apply the same transformation.Motivation
Remove unnecessary dependency. We unfortunately still use path in tests though.