From ab8abdc82ba73e8f83309dd20983ee04254f7f5b Mon Sep 17 00:00:00 2001 From: mae Date: Fri, 13 Mar 2026 01:01:23 -0500 Subject: [PATCH] cmd/pkgserver: pagination bugfix --- cmd/pkgserver/ui/static/index.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/pkgserver/ui/static/index.ts b/cmd/pkgserver/ui/static/index.ts index 18bbbfa..453964f 100644 --- a/cmd/pkgserver/ui/static/index.ts +++ b/cmd/pkgserver/ui/static/index.ts @@ -7,10 +7,10 @@ class PackageIndexEntry { report: boolean } function toHTML(entry: PackageIndexEntry): HTMLTableRowElement { - let v = entry.version !== null ? `${escapeHtml(entry.version)}` : "" - let s = entry.size !== null ? `

Size: ${toByteSizeString(entry.size)} (${entry.size})

` : "" - let d = entry.description !== null ? `

${escapeHtml(entry.description)}

` : "" - let w = entry.website !== null ? `Website` : "" + let v = entry.version != null ? `${escapeHtml(entry.version)}` : "" + let s = entry.size != null ? `

Size: ${toByteSizeString(entry.size)} (${entry.size})

` : "" + let d = entry.description != null ? `

${escapeHtml(entry.description)}

` : "" + let w = entry.website != null ? `Website` : "" let r = entry.report ? `Log (View | Download)` : "" let row = (document.createElement('tr')) row.innerHTML = ` @@ -24,7 +24,7 @@ function toHTML(entry: PackageIndexEntry): HTMLTableRowElement { } function toByteSizeString(bytes: number): string { - if(bytes < 1024) return `${bytes}B` + if(bytes == null || bytes < 1024) return `${bytes}B` if(bytes < Math.pow(1024, 2)) return `${(bytes/1024).toFixed(2)}kiB` if(bytes < Math.pow(1024, 3)) return `${(bytes/Math.pow(1024, 2)).toFixed(2)}MiB` if(bytes < Math.pow(1024, 4)) return `${(bytes/Math.pow(1024, 3)).toFixed(2)}GiB` @@ -50,7 +50,7 @@ class GetPayload { } enum SortOrders { - DeclarationAscending = 0, + DeclarationAscending, DeclarationDescending, NameAscending, NameDescending @@ -128,6 +128,7 @@ function nextPage() { } function escapeHtml(str: string): string { + if(str === undefined) return "" return str .replace(/&/g, '&') .replace(/