relayers-network-ui/utilities/getIPFSPrefix.ts

8 lines
218 B
TypeScript
Raw Normal View History

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