2024-10-27 21:27:41 +00:00
|
|
|
/* Copyright (C) 2024 Manuel Bustillo*/
|
|
|
|
|
2024-10-27 14:02:10 +01:00
|
|
|
export const getCsrfToken = () => {
|
|
|
|
return document.cookie
|
|
|
|
.split("; ")
|
|
|
|
.find((row) => row.startsWith("csrf-token"))
|
|
|
|
?.split("=")[1] || 'unknown';
|
|
|
|
}
|
2024-12-01 18:02:25 +01:00
|
|
|
|
|
|
|
export const getSlug = () => localStorage.getItem('slug') || 'default';
|
2024-12-01 22:59:07 +01:00
|
|
|
|
|
|
|
// From https://stackoverflow.com/a/1026087/3607039
|
|
|
|
export const capitalize = (val:string) => {
|
|
|
|
return String(val).charAt(0).toUpperCase() + String(val).slice(1);
|
|
|
|
}
|
2024-12-07 13:32:08 +01:00
|
|
|
|
|
|
|
// From https://stackoverflow.com/a/62118163/3607039
|
|
|
|
export function asArray<T>(value: T | T[]): T[] {
|
|
|
|
return ([] as T[]).concat(value)
|
|
|
|
}
|