Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 8988cc8

Browse files
committed
Add URI util
1 parent 8108330 commit 8988cc8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/utils/uri.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
export default {
2+
3+
isFileURI : (uri:string):boolean => {
4+
if(typeof uri !== 'string')
5+
return false
6+
return /^RNFetchBlob-file\:\/\//.test(uri)
7+
},
8+
9+
isJSONStreamURI : (uri:string):boolean => {
10+
if(typeof uri !== 'string')
11+
return false
12+
return /^JSONStream\:\/\//.test(uri)
13+
},
14+
15+
removeURIScheme : (uri:string, iterations:number):string => {
16+
iterations = iterations || 1
17+
let result = uri
18+
for(let i=0;i<iterations;i++) {
19+
result = String(result).replace(/^[^\:]+\:\/\//, '')
20+
}
21+
return String(result)
22+
},
23+
24+
unwrapFileURI : (uri:string):string => {
25+
return String(uri).replace(/^RNFetchBlob-file\:\/\//, '')
26+
}
27+
28+
}

0 commit comments

Comments
 (0)