1
0
Fork 0
VaultUI/src/utils.js

27 lines
526 B
JavaScript
Raw Normal View History

2021-04-15 13:01:58 +01:00
export function removeDoubleSlash(str) {
2021-04-15 15:37:52 +01:00
return str.replace(/\/\/+/g, "/");
2021-04-15 13:01:58 +01:00
}
export function getKeyByObjectPropertyValue(map, searchValue) {
2021-04-15 15:37:52 +01:00
for (let key of Object.getOwnPropertyNames(map)) {
if (map[key] === searchValue)
return key;
}
2021-04-15 13:01:58 +01:00
}
export function verifyJSONString(str) {
2021-04-15 15:37:52 +01:00
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
2021-04-15 13:01:58 +01:00
}
export function getToken() {
2021-04-15 15:37:52 +01:00
return localStorage.getItem('token');
2021-04-15 13:01:58 +01:00
}
export function getAPIURL() {
2021-04-15 15:37:52 +01:00
return localStorage.getItem('apiurl');
2021-04-15 13:01:58 +01:00
}