Fix issue #2244 Share Link incorrectly gives path routed instead of subdomain routed URL #1
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.
Bug
When you right click on a file in Files and choose "Share Link" you are given a URL like
https://<host>/ipfs/<cid>
. This should be of the formhttps://<cid>.ipfs.<host>
for security reasons.Solution
Modify the setting page and relevant code so that the user can adjust both subdomain and path gateway they use, but by default we use subdomain whenever possible
Code
getShareableLink
function insrc/lib/files.js
it nowGenerates a shareable link for the provided files using a subdomain gateway as default or a path gateway as fallback
src/bundles/gateway.js
a New functioncheckSubdomainGateway (gatewayUrl)
that Checks if a given gateway URL is functioning correctly by verifying image loading and redirection.settings/SettingsPage.js
and labels inpublic/locales/en/app.json
andpublic/locales/en/settings.json
##############
Tests: settings page
I've added a couple of tests in
test/e2e/settings.test.js
for submit/reset functionality of public gatewayAnd another test
src/lib/files.test.js
for checking subdomain and path gateway urls