TASK22269: normalize document hash-suffix route composition

This commit is contained in:
2026-03-25 14:13:53 +00:00
parent 4e964ad1ad
commit 1b7e6009aa
5 changed files with 55 additions and 7 deletions
@@ -70,7 +70,7 @@ const loadFileRouteBuilderModule = (injected = {}) => {
source = source.replace(/import[\s\S]*?from\s+"[^"]+";\n?/g, "");
source = source.replace(/export const\s+/g, "const ");
source +=
"\nmodule.exports = { buildFileQuery, withBaseUrl, appendQuerySuffix };\n";
"\nmodule.exports = { buildFileQuery, withBaseUrl, appendQuerySuffix, appendHashSuffix };\n";
const context = {
module: { exports: {} },
@@ -211,6 +211,12 @@ test("clients/fileRouteBuilder builds query with optional encoding and suffix he
mod.appendQuerySuffix(unencoded, "&hash=123"),
"/api/file/getbloblist?container=abc&casefolderID=x/y&hash=123"
);
assert.strictEqual(
mod.appendHashSuffix(unencoded, (route) =>
route.includes("getbloblist") ? "&hash=abc" : ""
),
"/api/file/getbloblist?container=abc&casefolderID=x/y&hash=abc"
);
});
const run = async () => {
+3
View File
@@ -200,6 +200,8 @@ const loadServiceModule = (fileName, injected = {}) => {
const defaultWithBaseUrl = (baseUrl, route) => `${baseUrl}${route}`;
const defaultAppendQuerySuffix = (route, suffix = "") =>
`${route}${suffix}`;
const defaultAppendHashSuffix = (route, hashBuilder) =>
defaultAppendQuerySuffix(route, hashBuilder(route));
const context = {
module: { exports: {} },
@@ -230,6 +232,7 @@ const loadServiceModule = (fileName, injected = {}) => {
withBaseUrl: injected.withBaseUrl || defaultWithBaseUrl,
appendQuerySuffix:
injected.appendQuerySuffix || defaultAppendQuerySuffix,
appendHashSuffix: injected.appendHashSuffix || defaultAppendHashSuffix,
...injected
};