- Delete old Vite+Svelte frontend - Initialize new SvelteKit project with TypeScript - Configure Tailwind CSS v4 + DaisyUI - Implement JWT authentication with auto-refresh - Create login page with form validation (Zod) - Add protected route guards - Update Docker configuration for single-stage build - Add E2E tests with Playwright (6/11 passing) - Fix Svelte 5 reactivity with $state() runes Known issues: - 5 E2E tests failing (timing/async issues) - Token refresh implementation needs debugging - Validation error display timing
60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
export const capitalize = (s) => (s[0].toUpperCase() + s.slice(1));
|
|
export const uncapitalize = (s) => (s[0].toLowerCase() + s.slice(1));
|
|
export const anchoredRegex = (regex) => new RegExp(anchoredSource(regex), typeof regex === "string" ? "" : regex.flags);
|
|
export const deanchoredRegex = (regex) => new RegExp(deanchoredSource(regex), typeof regex === "string" ? "" : regex.flags);
|
|
export const anchoredSource = (regex) => {
|
|
const source = typeof regex === "string" ? regex : regex.source;
|
|
return `^(?:${source})$`;
|
|
};
|
|
export const deanchoredSource = (regex) => {
|
|
const source = typeof regex === "string" ? regex : regex.source;
|
|
if (source.startsWith("^(?:") && source.endsWith(")$"))
|
|
return source.slice(4, -2);
|
|
return source.slice(source[0] === "^" ? 1 : 0, source[source.length - 1] === "$" ? -1 : undefined);
|
|
};
|
|
export const RegexPatterns = {
|
|
negativeLookahead: (pattern) => `(?!${pattern})`,
|
|
nonCapturingGroup: (pattern) => `(?:${pattern})`
|
|
};
|
|
export const Backslash = "\\";
|
|
export const whitespaceChars = {
|
|
" ": 1,
|
|
"\n": 1,
|
|
"\t": 1
|
|
};
|
|
export const emojiToUnicode = (emoji) => emoji
|
|
.split("")
|
|
.map(char => {
|
|
const codePoint = char.codePointAt(0);
|
|
return codePoint ? `\\u${codePoint.toString(16).padStart(4, "0")}` : "";
|
|
})
|
|
.join("");
|
|
export const alphabet = [
|
|
"a",
|
|
"b",
|
|
"c",
|
|
"d",
|
|
"e",
|
|
"f",
|
|
"g",
|
|
"h",
|
|
"i",
|
|
"j",
|
|
"k",
|
|
"l",
|
|
"m",
|
|
"n",
|
|
"o",
|
|
"p",
|
|
"q",
|
|
"r",
|
|
"s",
|
|
"t",
|
|
"u",
|
|
"v",
|
|
"w",
|
|
"x",
|
|
"y",
|
|
"z"
|
|
];
|