1
0
Fork 0

Add getObjectKeys.

This commit is contained in:
Kitteh 2021-05-05 21:30:45 +01:00
parent fa9f25027c
commit be0a597dfb
2 changed files with 7 additions and 5 deletions

View file

@ -1,5 +1,5 @@
import { DoesNotExistError } from "./types/internalErrors.js"; import { DoesNotExistError } from "./types/internalErrors.js";
import { getAPIURL, getToken, removeDoubleSlash } from "./utils.js"; import { getAPIURL, getObjectKeys, getToken, removeDoubleSlash } from "./utils.js";
export async function lookupSelf() { export async function lookupSelf() {
const request = new Request(getAPIURL() + "/v1/auth/token/lookup-self", { const request = new Request(getAPIURL() + "/v1/auth/token/lookup-self", {
@ -181,8 +181,8 @@ export async function undeleteSecret(baseMount, secretPath, name, version = null
pageState.currentSecretPath, pageState.currentSecretPath,
pageState.currentSecret pageState.currentSecret
); );
let versions = Array.from(new Map(Object.entries(meta.versions)).keys()) let versions = getObjectKeys(meta.versions);
version = String(versions[versions.length-1]) version = String(versions[versions.length-1]);
} }
let request = new Request(getAPIURL() + secretURL, { let request = new Request(getAPIURL() + secretURL, {

View file

@ -2,8 +2,10 @@ export function removeDoubleSlash(str) {
return str.replace(/\/\/+/g, "/"); return str.replace(/\/\/+/g, "/");
} }
export const getObjectKeys = (obj) => Object.getOwnPropertyNames(obj);
export function getKeyByObjectPropertyValue(map, searchValue) { export function getKeyByObjectPropertyValue(map, searchValue) {
for (let key of Object.getOwnPropertyNames(map)) { for (let key of getObjectKeys(map)) {
if (map[key] === searchValue) if (map[key] === searchValue)
return key; return key;
} }
@ -23,5 +25,5 @@ export function getToken() {
} }
export function getAPIURL() { export function getAPIURL() {
return pageState.apiURL.length > 0 ? pageState.apiURL : null return pageState.apiURL.length > 0 ? pageState.apiURL : null;
} }