Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

UI update: Fix link header parsing for log viewer (#1644)

Rich Turner80d7e9c803e3
diff --git a/ui/component/or-log-viewer/src/index.ts b/ui/component/or-log-viewer/src/index.ts
index 2d0a7e587..8a578eb89 100644
--- a/ui/component/or-log-viewer/src/index.ts
+++ b/ui/component/or-log-viewer/src/index.ts
@@ -485,10 +485,13 @@ export class OrLogViewer extends translate(i18next)(LitElement) {
const linkHeaders = response.headers["link"] as any;
if (linkHeaders) {
const links = linkParser.parse(linkHeaders);
- const lastLink = links.rel("last");
+ let lastLink = links.rel("last");
+ if (Array.isArray(lastLink) && lastLink.length > 0) {
+ lastLink = lastLink[0];
+ }
if (lastLink && lastLink.uri) {
const url = new URL(lastLink.uri);
- return Util.getQueryParameters(url.search)['page'] as number;
+ return parseInt(Util.getQueryParameters(url.search)['page']);
}
}
}