-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.js
35 lines (28 loc) · 1.08 KB
/
Utils.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
34
35
import {Platform, StyleSheet} from 'react-native';
export const APPBAR_HEIGHT = Platform.select({
ios: 100,
android: 100,
default: 64,
});
export const users = ["alex", "vanessa", "system", "carlos", "native"];
export const avatars = [
"https://avatars1.githubusercontent.com/u/6551029?s=460&v=4",
"https://avatars1.githubusercontent.com/u/3089882?s=460&v=4",
"https://avatars1.githubusercontent.com/u/89638?s=460&v=4",
"https://avatars0.githubusercontent.com/u/5570799?s=460&v=4",
"https://avatars1.githubusercontent.com/u/5710346?s=88&v=4",
];
function avatarFromNickname(nickname) {
let index = users.indexOf(nickname);
if(index != -1)
return avatars[index];
return "https://avatars2.githubusercontent.com/u/3019167?s=460&v=4"
}
function isValidUrl(url){
var res = url.match(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g);
return (res !== null)
}
function extractURL(text){
return text.match(/\bhttps?:\/\/\S+/gi);
}
export default {avatarFromNickname, isValidUrl, extractURL}