FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
uniswap-interface/src/utils/uriToHttp.ts at main · codeaudit/uniswap-interface · GitHub
codeaudit
/
uniswap-interface
Public
forked from
Uniswap/interface
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
uniswap-interface
/
src
/
utils
/
uriToHttp.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
21 lines (21 loc) · 773 Bytes
Breadcrumbs
uniswap-interface
/
src
/
utils
/
uriToHttp.ts
Copy path
File metadata and controls
21 lines (21 loc) · 773 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* Given a URI that may be ipfs, ipns, http, or https protocol, return the fetch-able http(s) URLs for the same content
*
@param
uri to convert to fetch-able http url
*/
export
default
function
uriToHttp
(
uri
:
string
)
:
string
[
]
{
const
protocol
=
uri
.
split
(
':'
)
[
0
]
.
toLowerCase
(
)
switch
(
protocol
)
{
case
'https'
:
return
[
uri
]
case
'http'
:
return
[
'https'
+
uri
.
substr
(
4
)
,
uri
]
case
'ipfs'
:
const
hash
=
uri
.
match
(
/
^
i
p
f
s
:
(
\/
\/
)
?
(
.
*
)
$
/
i
)
?.
[
2
]
return
[
`https://cloudflare-ipfs.com/ipfs/
${
hash
}
/`
,
`https://ipfs.io/ipfs/
${
hash
}
/`
]
case
'ipns'
:
const
name
=
uri
.
match
(
/
^
i
p
n
s
:
(
\/
\/
)
?
(
.
*
)
$
/
i
)
?.
[
2
]
return
[
`https://cloudflare-ipfs.com/ipns/
${
name
}
/`
,
`https://ipfs.io/ipns/
${
name
}
/`
]
default
:
return
[
]
}
}
Back
|
FazBrowse Home
|
New Git URL