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: redirect to native URI in Brave #960

Merged
merged 1 commit into from
Jan 17, 2021
Merged

Conversation

lidel
Copy link
Member

@lidel lidel commented Jan 17, 2021

This is a cosmetic fix that ensures IPFS resources are redirected to
ipfs:// or ipns:// URI and that URI is displayed in the browser UI
in the address bar.

Due to the way Brave implemented URI cloak for local HTTP-based gateway
provided by go-ipfs managed by the browser itself the regular redirect
done via webRequest API did not produce native URI in address bar.

However, tabs.update does the trick, so we use that for root requests.
We can remove this in the future, if webRequest behavior is fixed.

cc @autonome (mitigates issue we both discovered independently)

This is a cosmetic fix that ensures IPFS resources are redirected to
ipfs:// or ipns:// URI and that URI is displayed in the browser UI
in the address bar.

Due to the way Brave implemented URI cloak for local HTTP-based gateway
provided by go-ipfs managed by the browser itself the regular redirect
done via webRequest API did not produce native URI in address bar.

However, tabs.update does the trick, so we use that for root requests.
@lidel
Copy link
Member Author

lidel commented Jan 17, 2021

I'm fast-tracking this to Beta channel, so we can ship it together with #959 before BRave 1.19 hits Stable this week 💨

ln-infinity

@lidel lidel merged commit dbed296 into master Jan 17, 2021
@lidel lidel deleted the fix/redirect-to-native-uri-brave branch January 17, 2021 23:18
Copy link

@autonome autonome left a comment

Choose a reason for hiding this comment

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

couple minor comments, can be fixed as followups.

if (!contentPath) return null
return contentPath.replace(/^\/(ip[f|n]s)\//, '$1://')
}
exports.ipfsUri = ipfsUri

Choose a reason for hiding this comment

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

can you verbify the function name in a way that makes what it does more explicit?

it('should return null if there is no valid path for input path', function () {
const path = '/invalid/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR'
expect(ipfsUri(path)).to.equal(null)
})

Choose a reason for hiding this comment

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

lots of positive tests, should add negative tests too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants