Skip to content

Commit 1cd57ac

Browse files
committed
fix: Correct typo
1 parent 5336102 commit 1cd57ac

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/js/utils.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ export const climbLeftRightIndexComparator = (a: ClimbType, b: ClimbType): numbe
336336
export interface SortableAreaType { metadata: Pick<AreaMetadataType, 'leftRightIndex' | 'areaId'> }
337337

338338
export const areaLeftRightIndexComparator = (a: SortableAreaType, b: SortableAreaType): number => {
339-
const aIndex = a.metadata..leftRightIndex ?? -1
339+
const aIndex = a.metadata.leftRightIndex ?? -1
340340
const bIndex = b.metadata.leftRightIndex ?? -1
341341
if (aIndex < bIndex) return -1
342342
else if (aIndex > bIndex) return 1
@@ -359,6 +359,22 @@ export const parseUuidAsFirstParam = ({ params }: PageWithCatchAllUuidProps): st
359359
}
360360

361361
export const decodeAmpersand = (s: string): string => {
362-
if (s == null) return '';
363-
return s.replace(/&amp;/g, '&');
362+
if (s == null) return ''
363+
return s.replace(/&amp;/g, '&')
364+
}
365+
366+
export const safeDecode = (s: string): string => {
367+
if (s == null) return ''
368+
if (typeof window !== 'undefined') {
369+
const txt = document.createElement('textarea')
370+
txt.innerHTML = s
371+
return txt.value
372+
}
373+
// Basic SSR-safe decoding for common entities
374+
return s
375+
.replace(/&amp;/g, '&')
376+
.replace(/&lt;/g, '<')
377+
.replace(/&gt;/g, '>')
378+
.replace(/&quot;/g, '"')
379+
.replace(/&#39;/g, "'")
364380
}

0 commit comments

Comments
 (0)