From 53386909abf99395254879fef6a3c187eb6e171a Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 9 Mar 2022 10:12:26 +0000 Subject: [PATCH] Updating row search bookmark to handle numbers as bookmarks. --- packages/server/src/api/controllers/public/rows.ts | 3 ++- packages/server/src/utilities/index.js | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/public/rows.ts b/packages/server/src/api/controllers/public/rows.ts index e73bcf9b49..4a3b255a36 100644 --- a/packages/server/src/api/controllers/public/rows.ts +++ b/packages/server/src/api/controllers/public/rows.ts @@ -1,6 +1,7 @@ import { default as rowController } from "../row" import { addRev } from "./utils" import { Row } from "../../../definitions/common" +import { convertBookmark } from "../../../utilities" // makes sure that the user doesn't need to pass in the type, tableId or _id params for // the call to be correct @@ -30,7 +31,7 @@ export async function search(ctx: any, next: any) { sort: sort.column, sortType: sort.type, sortOrder: sort.order, - bookmark, + bookmark: convertBookmark(bookmark), paginate, limit, query, diff --git a/packages/server/src/utilities/index.js b/packages/server/src/utilities/index.js index d1e277541a..221c2ff18b 100644 --- a/packages/server/src/utilities/index.js +++ b/packages/server/src/utilities/index.js @@ -151,3 +151,11 @@ exports.formatBytes = bytes => { } return `${size.toFixed(size < 10 && unit > 0 ? 1 : 0)}${units[unit]}` } + +exports.convertBookmark = bookmark => { + const IS_NUMBER = /^\d+\.?\d*$/ + if (typeof bookmark === "string" && bookmark.match(IS_NUMBER)) { + return parseFloat(bookmark) + } + return bookmark +}