nova-ui/utilities/getIPFSPrefix.ts
2022-12-04 07:02:30 +01:00

8 lines
218 B
TypeScript

const PREFIX_INDEX = 1
const getIPFSPrefix = () => {
const ipfsPathRegExp = /^(\/(?:ipfs|ipns)\/[^/]+)/
return (window.location.pathname.match(ipfsPathRegExp) ?? [])[PREFIX_INDEX] || ''
}
export { getIPFSPrefix }