forked from RonRadtke/react-native-blob-util
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathuri.js
33 lines (27 loc) · 980 Bytes
/
uri.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
export default {
isFileURI: (uri: string): boolean => {
if (typeof uri !== 'string')
return false;
return /^ReactNativeBlobUtil-file\:\/\//.test(uri);
},
isJSONStreamURI: (uri: string): boolean => {
if (typeof uri !== 'string')
return false;
return /^JSONStream\:\/\//.test(uri);
},
removeURIScheme: (uri: string, iterations: number): string => {
iterations = iterations || 1;
let result = uri;
for (let i = 0; i < iterations; i++) {
result = String(result).replace(/^[^\:]+\:\/\//, '');
}
return String(result);
},
unwrapFileURI: (uri: string): string => {
return String(uri).replace(/^ReactNativeBlobUtil-file\:\/\//, '');
},
wrap: (path: string): string => {
const prefix = path.startsWith('content://') ? 'ReactNativeBlobUtil-content://' : 'ReactNativeBlobUtil-file://';
return prefix + path;
}
};