|
|
@@ -1,5 +1,3 @@
|
|
|
-import { type } from 'os';
|
|
|
-
|
|
|
import { ErrorV3 } from '@growi/core';
|
|
|
import express, { Request, Router } from 'express';
|
|
|
import { query, oneOf } from 'express-validator';
|
|
|
@@ -37,7 +35,7 @@ const validator = {
|
|
|
query('path').isString(),
|
|
|
], 'id or path is required'),
|
|
|
pageIdsOrPathRequired: oneOf([
|
|
|
- query('pageIds').isString(),
|
|
|
+ query('pageIds').isArray(),
|
|
|
query('path').isString(),
|
|
|
], 'pageIds or path is required'),
|
|
|
infoParams: [
|
|
|
@@ -110,6 +108,7 @@ const routerFactory = (crowi: Crowi): Router => {
|
|
|
const {
|
|
|
pageIds, path, attachBookmarkCount: attachBookmarkCountParam, attachShortBody: attachShortBodyParam,
|
|
|
} = req.query;
|
|
|
+
|
|
|
const attachBookmarkCount: boolean = attachBookmarkCountParam === 'true';
|
|
|
const attachShortBody: boolean = attachShortBodyParam === 'true';
|
|
|
|
|
|
@@ -119,12 +118,8 @@ const routerFactory = (crowi: Crowi): Router => {
|
|
|
const pageService: PageService = crowi.pageService!;
|
|
|
|
|
|
try {
|
|
|
- // see: https://github.com/expressjs/body-parser/issues/289
|
|
|
- // If an array of 20 or more is included in req.query, it is converted to an object with the index as a key, so the client passes JSON.stringify values
|
|
|
- const parsedPageIds = JSON.parse(pageIds as string);
|
|
|
-
|
|
|
- const pages = parsedPageIds != null && parsedPageIds.length > 0
|
|
|
- ? await Page.findByIdsAndViewer(parsedPageIds as string[], req.user, null, true)
|
|
|
+ const pages = pageIds != null
|
|
|
+ ? await Page.findByIdsAndViewer(pageIds as string[], req.user, null, true)
|
|
|
: await Page.findByPathAndViewer(path as string, req.user, null, false, true);
|
|
|
|
|
|
const foundIds = pages.map(page => page._id);
|