-
Notifications
You must be signed in to change notification settings - Fork 22
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
Feat/add iana ipfs #95
base: main
Are you sure you want to change the base?
Conversation
This correctly detects subdomains with DNSLink name inlined into a single DNS label. More details: ipfs/in-web-browsers#169 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
- Fixes ipfs-shipyard#48
…domains' into feat/add-iana-ipfs
@@ -0,0 +1,182 @@ | |||
'use strict' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file shouldn't be committed here. might have been extra from a manual tsc
run?
isIPFS.urlOrPath('https://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va.ipfs.dweb.link') // true | ||
isIPFS.urlOrPath('https://google.com') // false | ||
|
||
isIPFS.ipfsUrl('https://ipfs.io/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // true | ||
isIPFS.ipfsUrl('https://ipfs.io/ipfs/invalid-hash') // false | ||
isIPFS.ipfsUrl('ipfs://ipfs.io/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isIPFS.ipfsUrl('ipfs://ipfs.io/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // true | |
isIPFS.ipfsUrl('ipfs://ipfs.io/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // false |
this should return as invalid since it should have a CID as the "domain" when "ipfs" is the protocol
|
||
isIPFS.ipnsUrl('https://ipfs.io/ipfs/QmYjtig7VJQ6XsnUjqqJvj7QaMcCAwtrgNdahSiFofrE7o') // false | ||
isIPFS.ipnsUrl('https://ipfs.io/ipns/github.com') // true | ||
isIPFS.ipnsUrl('ipns://ipfs.io/ipns/github.com') // true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return as true because ipfs.io might reference a valid dnslink, but the /ipns/<domain>
might confuse users. we should remove this, or just use ipns://<validDnsLink>
also we should probably show invalid here:
- ipns://CID is invalid
- ipns:// is invalid
- ipns:// is invalid
|
||
describe('ipns path', () => { | ||
it('isIPFS.urlOrPath should match an IANA-schema compliant ipns url', () => { | ||
expect(isIPFS.urlOrPath('ipns://QmYHNYAaYK5hm3ZhZFx5W9H6xydKDGimjdgJMrMSdnctEm')).to.be.true() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(isIPFS.urlOrPath('ipns://QmYHNYAaYK5hm3ZhZFx5W9H6xydKDGimjdgJMrMSdnctEm')).to.be.true() | |
expect(isIPFS.urlOrPath('ipns://QmYHNYAaYK5hm3ZhZFx5W9H6xydKDGimjdgJMrMSdnctEm')).to.be.false() |
ipns:// is not valid. Only keys and domains are valid.
No description provided.