diff --git a/lib/cookieCleanup.ts b/lib/cookieCleanup.ts index 2d7a215..725d026 100644 --- a/lib/cookieCleanup.ts +++ b/lib/cookieCleanup.ts @@ -15,19 +15,16 @@ export function deleteAllCookies(): void { for (let i = 0; i < cookies.length; i += 1) { const cookie = cookies[i] - if (!cookie) { - continue - } - const eqPos = cookie.indexOf('=') - const name = eqPos > -1 ? cookie.substring(0, eqPos).trim() : cookie.trim() + if (cookie) { + const eqPos = cookie.indexOf('=') + const name = eqPos > -1 ? cookie.substring(0, eqPos).trim() : cookie.trim() - if (!name) { - continue + if (name) { + // Delete cookie by setting it to expire in the past + document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/` + document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=${window.location.hostname}` + document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=.${window.location.hostname}` + } } - - // Delete cookie by setting it to expire in the past - document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/` - document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=${window.location.hostname}` - document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=.${window.location.hostname}` } } diff --git a/lib/hashIdGenerator.ts b/lib/hashIdGenerator.ts index 398ddef..a13cf41 100644 --- a/lib/hashIdGenerator.ts +++ b/lib/hashIdGenerator.ts @@ -14,17 +14,16 @@ function canonicalizeObject(obj: Record): string { for (const key of sortedKeys) { const value = obj[key] - if (value === undefined || value === null) { - continue // Skip undefined/null values - } - if (typeof value === 'object' && !Array.isArray(value)) { - // Recursively canonicalize nested objects - parts.push(`${key}:${canonicalizeObject(value as Record)}`) - } else if (Array.isArray(value)) { - // Arrays are serialized as comma-separated values - parts.push(`${key}:[${value.map((v) => (typeof v === 'object' ? JSON.stringify(v) : String(v))).join(',')}]`) - } else { - parts.push(`${key}:${String(value)}`) + if (value !== undefined && value !== null) { + if (typeof value === 'object' && !Array.isArray(value)) { + // Recursively canonicalize nested objects + parts.push(`${key}:${canonicalizeObject(value as Record)}`) + } else if (Array.isArray(value)) { + // Arrays are serialized as comma-separated values + parts.push(`${key}:[${value.map((v) => (typeof v === 'object' ? JSON.stringify(v) : String(v))).join(',')}]`) + } else { + parts.push(`${key}:${String(value)}`) + } } } diff --git a/lib/i18n.ts b/lib/i18n.ts index 94a37c7..2beb617 100644 --- a/lib/i18n.ts +++ b/lib/i18n.ts @@ -36,17 +36,15 @@ export function loadTranslations(locale: Locale, translationsText: string): void const lines = translationsText.split('\n') for (const line of lines) { const trimmed = line.trim() - if (!trimmed || trimmed.startsWith('#')) { - continue - } - const equalIndex = trimmed.indexOf('=') - if (equalIndex === -1) { - continue - } - const key = trimmed.substring(0, equalIndex).trim() - const value = trimmed.substring(equalIndex + 1).trim() - if (key && value) { - translationsMap[key] = value + if (trimmed && !trimmed.startsWith('#')) { + const equalIndex = trimmed.indexOf('=') + if (equalIndex !== -1) { + const key = trimmed.substring(0, equalIndex).trim() + const value = trimmed.substring(equalIndex + 1).trim() + if (key && value) { + translationsMap[key] = value + } + } } } diff --git a/lib/markdownRenderer.tsx b/lib/markdownRenderer.tsx index 14b598a..8e72093 100644 --- a/lib/markdownRenderer.tsx +++ b/lib/markdownRenderer.tsx @@ -175,18 +175,17 @@ function renderLink(line: string, index: number, elements: React.ReactElement[]) let match while ((match = linkRegex.exec(line)) !== null) { - if (!match[2]) { - continue + if (match[2]) { + if (!match[1] || match.index > lastIndex) { + parts.push(line.substring(lastIndex, match.index)) + } + const href = match[2] + const isExternal = href.startsWith('http') + if (match[1]) { + parts.push(createLinkElement(match[1], href, `link-${index}-${match.index}`, isExternal)) + } + lastIndex = match.index + match[0].length } - if (!match[1] || match.index > lastIndex) { - parts.push(line.substring(lastIndex, match.index)) - } - const href = match[2] - const isExternal = href.startsWith('http') - if (match[1]) { - parts.push(createLinkElement(match[1], href, `link-${index}-${match.index}`, isExternal)) - } - lastIndex = match.index + match[0].length } if (lastIndex < line.length) {