Append port to the base URL if defined when generating public URLs #6
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.
Hey! 👋
Following a discussion with @thetutlage on Discord and at his request, I created this PR to address an issue with the getUrl() method: if an S3 endpoint includes a port, the port is stripped when generating a public URL, resulting in an incorrect URL.
This PR fixes this behaviour by adding the port only if it's defined.
This PR will be a draft until Virk decides on another question. When
cdnUrl
is used, if it doesn't have a trailing slash, the pathname will be removed and the bucket used will not be included in the public URL generated by the getUrl() method. The following is an example for the same:In this case, using
await drive.use().getUrl('foo/bar.png')
will result in the following generated URL:http://localhost:9000/foo/bar.png
which is wrong. The correct URL should be:http://localhost:9000/local/foo/bar.png
.To address this issue, we can either add a trailing slash automatically to cdnUrl, or let devs do it manually, i.e :
I can work on the second issue too, if necessary.
Thank you!