@growi/core 3.1.2 → 3.1.3-next.2a5da17fbf4bb500cbcdc1b0c38ee74d3054929f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../objectid-utils.cjs"),s=require("../path-utils.cjs"),n=require("./exceeds-max-page-depth.cjs"),d=require("./is-top-page.cjs"),f=require("./generate-children-regexp.cjs"),i=d.isTopPage,o=e=>e==="/user",x=e=>{const t=e.substring(1);return m.isValidObjectId(t)},c=e=>!!e.match(/^\/user\/[^/]+$/),h=e=>o(e)||c(e),$=e=>!i(e)&&!h(e),E=e=>!!e.match(/^\/user\/.*?$/),T=e=>e==="/trash",w=e=>!!e.match(/^\/trash(\/.*)?$/),A=e=>!!e.match(/^\/share(\/.*)?$/),S=[/\^|\$|\*|\+|#|<|>|%|\?/,/^\/-\/.*/,/^\/_r\/.*/,/^\/_apix?(\/.*)?/,/^\/?https?:\/\/.+$/,/\/{2,}/,/\s\/\s/,/.\/edit$/,/.\.md$/,/^(\.\.)$/,/(\/\.\.)\/?/,/\\/,/^\/(_search|_private-legacy-pages|_news)(\/.*|$)/,/^\/(installer|register|login|logout|admin|me|files|trash|paste|comments|tags|share|attachment)(\/.*|$)/,/^\/user(?:\/[^/]+)?$/],l=e=>!S.some(t=>e.match(t))&&!n.exceedsMaxPageDepth(e),v=e=>(e==null?void 0:e.username)==null?"":`/user/${e.username}`,b=(e,t,r)=>{if(t==null)throw new Error("Please input the new page path");const a=new RegExp(`^${RegExp.escape(e)}`,"i");return r.replace(a,t)},R=e=>{if(e!=null)return e.replace(/ /g,"%20").replace(/\u3000/g,"%E3%80%80")},U=(...e)=>{const t=[...e].join("/");if(!l(t))throw new Error("Invalid characters on path");try{return`${new URL(t,"https://dummy").pathname}#edit`}catch{throw new Error("Invalid path format")}},u=(e,t)=>{const r=`${t}/`.toLowerCase(),a=e.toLowerCase();return a.length>r.length&&a.startsWith(r)},y=e=>{const t=Array.from(new Set(e));return t.filter(r=>!t.some(a=>u(r,a)))},C=e=>e.filter(t=>!e.some(r=>u(t.path,r.path))),D=(e,t)=>{if(e===t)return!0;const r=s.addTrailingSlash(e),a=s.addTrailingSlash(t),P=new RegExp(`^${RegExp.escape(r)}`,"i"),p=new RegExp(`^${RegExp.escape(a)}`,"i");return!!(P.test(t)||p.test(e))},g=(e,t)=>{if(e===t)return!0;const r=s.addTrailingSlash(e);return!!new RegExp(`^${RegExp.escape(r)}`,"i").test(t)},M=(e,t)=>!g(e,t),O=e=>e.includes("/"),q=e=>{let t=null;const r=e.match(/^\/user\/([^/]+)\/?/);return r&&(t=r[1]),t},j=e=>/^(?:\/[^/*?[\]{}]+)*\/\*$/.test(e);exports.exceedsMaxPageDepth=n.exceedsMaxPageDepth;exports.generateChildrenRegExp=f.generateChildrenRegExp;exports.canMoveByPath=M;exports.convertToNewAffiliationPath=b;exports.encodeSpaces=R;exports.generateEditorPath=U;exports.getUsernameByPath=q;exports.hasSlash=O;exports.isCreatablePage=l;exports.isEitherOfPathAreaOverlap=D;exports.isGlobPatternPath=j;exports.isMovablePage=$;exports.isPathAreaOverlap=g;exports.isPermalink=x;exports.isSharedPage=A;exports.isTopPage=i;exports.isTrashPage=w;exports.isTrashTopPage=T;exports.isUserPage=E;exports.isUsersHomepage=c;exports.isUsersProtectedPages=h;exports.isUsersTopPage=o;exports.omitDuplicateAreaPageFromPages=C;exports.omitDuplicateAreaPathFromPaths=y;exports.userHomepagePath=v;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/utils/page-path-utils/index.ts"],"sourcesContent":["import { isValidObjectId } from '../objectid-utils.js';\nimport { addTrailingSlash } from '../path-utils.js';\nimport { exceedsMaxPageDepth } from './exceeds-max-page-depth.js';\nimport { isTopPage as _isTopPage } from './is-top-page.js';\n\nexport const isTopPage = _isTopPage;\n\nexport * from './generate-children-regexp.js';\n\n/**\n * Whether path is the top page of users\n * @param path\n */\nexport const isUsersTopPage = (path: string): boolean => {\n return path === '/user';\n};\n\n/**\n * Whether the path is permalink\n * @param path\n */\nexport const isPermalink = (path: string): boolean => {\n const pageIdStr = path.substring(1);\n return isValidObjectId(pageIdStr);\n};\n\n/**\n * Whether path is user's homepage\n * @param path\n */\nexport const isUsersHomepage = (path: string): boolean => {\n // https://regex101.com/r/utVQct/1\n if (path.match(/^\\/user\\/[^/]+$/)) {\n return true;\n }\n return false;\n};\n\n/**\n * Whether path is the protected pages for systems\n * @param path\n */\nexport const isUsersProtectedPages = (path: string): boolean => {\n return isUsersTopPage(path) || isUsersHomepage(path);\n};\n\n/**\n * Whether path is movable\n * @param path\n */\nexport const isMovablePage = (path: string): boolean => {\n return !isTopPage(path) && !isUsersProtectedPages(path);\n};\n\n/**\n * Whether path belongs to the user page\n * @param path\n */\nexport const isUserPage = (path: string): boolean => {\n // https://regex101.com/r/MwifLR/1\n if (path.match(/^\\/user\\/.*?$/)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Whether path is the top page of users\n * @param path\n */\nexport const isTrashTopPage = (path: string): boolean => {\n return path === '/trash';\n};\n\n/**\n * Whether path belongs to the trash page\n * @param path\n */\nexport const isTrashPage = (path: string): boolean => {\n // https://regex101.com/r/BSDdRr/1\n if (path.match(/^\\/trash(\\/.*)?$/)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Whether path belongs to the shared page\n * @param path\n */\nexport const isSharedPage = (path: string): boolean => {\n // https://regex101.com/r/ZjdOiB/1\n if (path.match(/^\\/share(\\/.*)?$/)) {\n return true;\n }\n\n return false;\n};\n\nconst restrictedPatternsToCreate: Array<RegExp> = [\n /\\^|\\$|\\*|\\+|#|<|>|%|\\?/,\n /^\\/-\\/.*/,\n /^\\/_r\\/.*/,\n /^\\/_apix?(\\/.*)?/,\n /^\\/?https?:\\/\\/.+$/, // avoid miss in renaming\n /\\/{2,}/, // avoid miss in renaming\n /\\s\\/\\s/, // avoid miss in renaming\n /.\\/edit$/,\n /.\\.md$/,\n /^(\\.\\.)$/, // see: https://github.com/growilabs/growi/issues/3582\n /(\\/\\.\\.)\\/?/, // see: https://github.com/growilabs/growi/issues/3582\n /\\\\/, // see: https://github.com/growilabs/growi/issues/7241\n /^\\/(_search|_private-legacy-pages|_news)(\\/.*|$)/,\n /^\\/(installer|register|login|logout|admin|me|files|trash|paste|comments|tags|share|attachment)(\\/.*|$)/,\n /^\\/user(?:\\/[^/]+)?$/, // https://regex101.com/r/9Eh2S1/1\n];\n\nexport const isCreatablePage = (path: string): boolean => {\n return (\n !restrictedPatternsToCreate.some((pattern) => path.match(pattern)) &&\n !exceedsMaxPageDepth(path)\n );\n};\n\n/**\n * return user's homepage path\n * @param user\n */\nexport const userHomepagePath = (\n user: { username: string } | null | undefined,\n): string => {\n if (user?.username == null) {\n return '';\n }\n return `/user/${user.username}`;\n};\n\n/**\n * return user path\n * @param parentPath\n * @param childPath\n * @param newPath\n */\nexport const convertToNewAffiliationPath = (\n oldPath: string,\n newPath: string,\n childPath: string,\n): string => {\n if (newPath == null) {\n throw new Error('Please input the new page path');\n }\n const pathRegExp = new RegExp(`^${RegExp.escape(oldPath)}`, 'i');\n return childPath.replace(pathRegExp, newPath);\n};\n\n/**\n * Encode SPACE and IDEOGRAPHIC SPACE\n * @param {string} path\n * @returns {string}\n */\nexport const encodeSpaces = (path?: string): string | undefined => {\n if (path == null) {\n return undefined;\n }\n\n // Encode SPACE and IDEOGRAPHIC SPACE\n return path.replace(/ /g, '%20').replace(/\\u3000/g, '%E3%80%80');\n};\n\n/**\n * Generate editor path\n * @param {string} paths\n * @returns {string}\n */\nexport const generateEditorPath = (...paths: string[]): string => {\n const joinedPath = [...paths].join('/');\n\n if (!isCreatablePage(joinedPath)) {\n throw new Error('Invalid characters on path');\n }\n\n try {\n const url = new URL(joinedPath, 'https://dummy');\n return `${url.pathname}#edit`;\n } catch {\n throw new Error('Invalid path format');\n }\n};\n\n/**\n * return paths without duplicate area of regexp /^${path}\\/.+/i\n * ex. expect(omitDuplicateAreaPathFromPaths(['/A', '/A/B', '/A/B/C'])).toStrictEqual(['/A'])\n * @param paths paths to be tested\n * @returns omitted paths\n */\nexport const omitDuplicateAreaPathFromPaths = (paths: string[]): string[] => {\n const uniquePaths = Array.from(new Set(paths));\n return uniquePaths.filter((path) => {\n const isDuplicate =\n uniquePaths.filter((p) => new RegExp(`^${p}\\\\/.+`, 'i').test(path))\n .length > 0;\n\n return !isDuplicate;\n });\n};\n\n/**\n * return pages with path without duplicate area of regexp /^${path}\\/.+/i\n * if the pages' path are the same, it will NOT omit any of them since the other attributes will not be the same\n * @param paths paths to be tested\n * @returns omitted paths\n */\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const omitDuplicateAreaPageFromPages = (pages: any[]): any[] => {\n return pages.filter((page) => {\n const isDuplicate = pages.some((p) =>\n new RegExp(`^${p.path}\\\\/.+`, 'i').test(page.path),\n );\n\n return !isDuplicate;\n });\n};\n\n/**\n * Check if the area of either path1 or path2 includes the area of the other path\n * The area of path is the same as /^\\/hoge\\//i\n * @param pathToTest string\n * @param pathToBeTested string\n * @returns boolean\n */\nexport const isEitherOfPathAreaOverlap = (\n path1: string,\n path2: string,\n): boolean => {\n if (path1 === path2) {\n return true;\n }\n\n const path1WithSlash = addTrailingSlash(path1);\n const path2WithSlash = addTrailingSlash(path2);\n\n const path1Area = new RegExp(`^${RegExp.escape(path1WithSlash)}`, 'i');\n const path2Area = new RegExp(`^${RegExp.escape(path2WithSlash)}`, 'i');\n\n if (path1Area.test(path2) || path2Area.test(path1)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Check if the area of pathToTest includes the area of pathToBeTested\n * The area of path is the same as /^\\/hoge\\//i\n * @param pathToTest string\n * @param pathToBeTested string\n * @returns boolean\n */\nexport const isPathAreaOverlap = (\n pathToTest: string,\n pathToBeTested: string,\n): boolean => {\n if (pathToTest === pathToBeTested) {\n return true;\n }\n\n const pathWithSlash = addTrailingSlash(pathToTest);\n\n const pathAreaToTest = new RegExp(`^${RegExp.escape(pathWithSlash)}`, 'i');\n if (pathAreaToTest.test(pathToBeTested)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Determine whether can move by fromPath and toPath\n * @param fromPath string\n * @param toPath string\n * @returns boolean\n */\nexport const canMoveByPath = (fromPath: string, toPath: string): boolean => {\n return !isPathAreaOverlap(fromPath, toPath);\n};\n\n/**\n * check if string has '/' in it\n */\nexport const hasSlash = (str: string): boolean => {\n return str.includes('/');\n};\n\n/**\n * Get username from user page path\n * @param path string\n * @returns string | null\n */\nexport const getUsernameByPath = (path: string): string | null => {\n let username: string | null = null;\n // https://regex101.com/r/qj4SfD/1\n const match = path.match(/^\\/user\\/([^/]+)\\/?/);\n if (match) {\n username = match[1];\n }\n\n return username;\n};\n\nexport const isGlobPatternPath = (path: string): boolean => {\n // https://regex101.com/r/IBy7HS/1\n const globPattern = /^(?:\\/[^/*?[\\]{}]+)*\\/\\*$/;\n return globPattern.test(path);\n};\n\nexport * from './exceeds-max-page-depth.js';\nexport * from './is-top-page.js';\n"],"names":["isTopPage","_isTopPage","isUsersTopPage","path","isPermalink","pageIdStr","isValidObjectId","isUsersHomepage","isUsersProtectedPages","isMovablePage","isUserPage","isTrashTopPage","isTrashPage","isSharedPage","restrictedPatternsToCreate","isCreatablePage","pattern","exceedsMaxPageDepth","userHomepagePath","user","convertToNewAffiliationPath","oldPath","newPath","childPath","pathRegExp","encodeSpaces","generateEditorPath","paths","joinedPath","omitDuplicateAreaPathFromPaths","uniquePaths","p","omitDuplicateAreaPageFromPages","pages","page","isEitherOfPathAreaOverlap","path1","path2","path1WithSlash","addTrailingSlash","path2WithSlash","path1Area","path2Area","isPathAreaOverlap","pathToTest","pathToBeTested","pathWithSlash","canMoveByPath","fromPath","toP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CAAM,EAM/BC,EAAYC,GAChBA,EAAI,SAAS,GAAG,EAQZC,EAAqBjD,GAAgC,CAChE,IAAIkD,EAA0B,KAE9B,MAAMC,EAAQnD,EAAK,MAAM,qBAAqB,EAC9C,OAAImD,IACFD,EAAWC,EAAM,CAAC,GAGbD,CACT,EAEaE,EAAqBpD,GAEZ,4BACD,KAAKA,CAAI"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/utils/page-path-utils/index.ts"],"sourcesContent":["import { isValidObjectId } from '../objectid-utils.js';\nimport { addTrailingSlash } from '../path-utils.js';\nimport { exceedsMaxPageDepth } from './exceeds-max-page-depth.js';\nimport { isTopPage as _isTopPage } from './is-top-page.js';\n\nexport const isTopPage = _isTopPage;\n\nexport * from './generate-children-regexp.js';\n\n/**\n * Whether path is the top page of users\n * @param path\n */\nexport const isUsersTopPage = (path: string): boolean => {\n return path === '/user';\n};\n\n/**\n * Whether the path is permalink\n * @param path\n */\nexport const isPermalink = (path: string): boolean => {\n const pageIdStr = path.substring(1);\n return isValidObjectId(pageIdStr);\n};\n\n/**\n * Whether path is user's homepage\n * @param path\n */\nexport const isUsersHomepage = (path: string): boolean => {\n // https://regex101.com/r/utVQct/1\n if (path.match(/^\\/user\\/[^/]+$/)) {\n return true;\n }\n return false;\n};\n\n/**\n * Whether path is the protected pages for systems\n * @param path\n */\nexport const isUsersProtectedPages = (path: string): boolean => {\n return isUsersTopPage(path) || isUsersHomepage(path);\n};\n\n/**\n * Whether path is movable\n * @param path\n */\nexport const isMovablePage = (path: string): boolean => {\n return !isTopPage(path) && !isUsersProtectedPages(path);\n};\n\n/**\n * Whether path belongs to the user page\n * @param path\n */\nexport const isUserPage = (path: string): boolean => {\n // https://regex101.com/r/MwifLR/1\n if (path.match(/^\\/user\\/.*?$/)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Whether path is the top page of users\n * @param path\n */\nexport const isTrashTopPage = (path: string): boolean => {\n return path === '/trash';\n};\n\n/**\n * Whether path belongs to the trash page\n * @param path\n */\nexport const isTrashPage = (path: string): boolean => {\n // https://regex101.com/r/BSDdRr/1\n if (path.match(/^\\/trash(\\/.*)?$/)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Whether path belongs to the shared page\n * @param path\n */\nexport const isSharedPage = (path: string): boolean => {\n // https://regex101.com/r/ZjdOiB/1\n if (path.match(/^\\/share(\\/.*)?$/)) {\n return true;\n }\n\n return false;\n};\n\nconst restrictedPatternsToCreate: Array<RegExp> = [\n /\\^|\\$|\\*|\\+|#|<|>|%|\\?/,\n /^\\/-\\/.*/,\n /^\\/_r\\/.*/,\n /^\\/_apix?(\\/.*)?/,\n /^\\/?https?:\\/\\/.+$/, // avoid miss in renaming\n /\\/{2,}/, // avoid miss in renaming\n /\\s\\/\\s/, // avoid miss in renaming\n /.\\/edit$/,\n /.\\.md$/,\n /^(\\.\\.)$/, // see: https://github.com/growilabs/growi/issues/3582\n /(\\/\\.\\.)\\/?/, // see: https://github.com/growilabs/growi/issues/3582\n /\\\\/, // see: https://github.com/growilabs/growi/issues/7241\n /^\\/(_search|_private-legacy-pages|_news)(\\/.*|$)/,\n /^\\/(installer|register|login|logout|admin|me|files|trash|paste|comments|tags|share|attachment)(\\/.*|$)/,\n /^\\/user(?:\\/[^/]+)?$/, // https://regex101.com/r/9Eh2S1/1\n];\n\nexport const isCreatablePage = (path: string): boolean => {\n return (\n !restrictedPatternsToCreate.some((pattern) => path.match(pattern)) &&\n !exceedsMaxPageDepth(path)\n );\n};\n\n/**\n * return user's homepage path\n * @param user\n */\nexport const userHomepagePath = (\n user: { username: string } | null | undefined,\n): string => {\n if (user?.username == null) {\n return '';\n }\n return `/user/${user.username}`;\n};\n\n/**\n * return user path\n * @param parentPath\n * @param childPath\n * @param newPath\n */\nexport const convertToNewAffiliationPath = (\n oldPath: string,\n newPath: string,\n childPath: string,\n): string => {\n if (newPath == null) {\n throw new Error('Please input the new page path');\n }\n const pathRegExp = new RegExp(`^${RegExp.escape(oldPath)}`, 'i');\n return childPath.replace(pathRegExp, newPath);\n};\n\n/**\n * Encode SPACE and IDEOGRAPHIC SPACE\n * @param {string} path\n * @returns {string}\n */\nexport const encodeSpaces = (path?: string): string | undefined => {\n if (path == null) {\n return undefined;\n }\n\n // Encode SPACE and IDEOGRAPHIC SPACE\n return path.replace(/ /g, '%20').replace(/\\u3000/g, '%E3%80%80');\n};\n\n/**\n * Generate editor path\n * @param {string} paths\n * @returns {string}\n */\nexport const generateEditorPath = (...paths: string[]): string => {\n const joinedPath = [...paths].join('/');\n\n if (!isCreatablePage(joinedPath)) {\n throw new Error('Invalid characters on path');\n }\n\n try {\n const url = new URL(joinedPath, 'https://dummy');\n return `${url.pathname}#edit`;\n } catch {\n throw new Error('Invalid path format');\n }\n};\n\n// Same result as /^${areaPath}\\/.+/i for ordinary paths, with areaPath matched literally\nconst isInDescendantArea = (path: string, areaPath: string): boolean => {\n const prefix = `${areaPath}/`.toLowerCase();\n const lowerCasedPath = path.toLowerCase();\n return (\n lowerCasedPath.length > prefix.length && lowerCasedPath.startsWith(prefix)\n );\n};\n\n/**\n * return paths without duplicate area of regexp /^${path}\\/.+/i\n * ex. expect(omitDuplicateAreaPathFromPaths(['/A', '/A/B', '/A/B/C'])).toStrictEqual(['/A'])\n * @param paths paths to be tested\n * @returns omitted paths\n */\nexport const omitDuplicateAreaPathFromPaths = (paths: string[]): string[] => {\n const uniquePaths = Array.from(new Set(paths));\n return uniquePaths.filter((path) => {\n return !uniquePaths.some((p) => isInDescendantArea(path, p));\n });\n};\n\n/**\n * return pages with path without duplicate area of regexp /^${path}\\/.+/i\n * if the pages' path are the same, it will NOT omit any of them since the other attributes will not be the same\n * @param paths paths to be tested\n * @returns omitted paths\n */\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const omitDuplicateAreaPageFromPages = (pages: any[]): any[] => {\n return pages.filter((page) => {\n return !pages.some((p) => isInDescendantArea(page.path, p.path));\n });\n};\n\n/**\n * Check if the area of either path1 or path2 includes the area of the other path\n * The area of path is the same as /^\\/hoge\\//i\n * @param pathToTest string\n * @param pathToBeTested string\n * @returns boolean\n */\nexport const isEitherOfPathAreaOverlap = (\n path1: string,\n path2: string,\n): boolean => {\n if (path1 === path2) {\n return true;\n }\n\n const path1WithSlash = addTrailingSlash(path1);\n const path2WithSlash = addTrailingSlash(path2);\n\n const path1Area = new RegExp(`^${RegExp.escape(path1WithSlash)}`, 'i');\n const path2Area = new RegExp(`^${RegExp.escape(path2WithSlash)}`, 'i');\n\n if (path1Area.test(path2) || path2Area.test(path1)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Check if the area of pathToTest includes the area of pathToBeTested\n * The area of path is the same as /^\\/hoge\\//i\n * @param pathToTest string\n * @param pathToBeTested string\n * @returns boolean\n */\nexport const isPathAreaOverlap = (\n pathToTest: string,\n pathToBeTested: string,\n): boolean => {\n if (pathToTest === pathToBeTested) {\n return true;\n }\n\n const pathWithSlash = addTrailingSlash(pathToTest);\n\n const pathAreaToTest = new RegExp(`^${RegExp.escape(pathWithSlash)}`, 'i');\n if (pathAreaToTest.test(pathToBeTested)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Determine whether can move by fromPath and toPath\n * @param fromPath string\n * @param toPath string\n * @returns boolean\n */\nexport const canMoveByPath = (fromPath: string, toPath: string): boolean => {\n return !isPathAreaOverlap(fromPath, toPath);\n};\n\n/**\n * check if string has '/' in it\n */\nexport const hasSlash = (str: string): boolean => {\n return str.includes('/');\n};\n\n/**\n * Get username from user page path\n * @param path string\n * @returns string | null\n */\nexport const getUsernameByPath = (path: string): string | null => {\n let username: string | null = null;\n // https://regex101.com/r/qj4SfD/1\n const match = path.match(/^\\/user\\/([^/]+)\\/?/);\n if (match) {\n username = match[1];\n }\n\n return username;\n};\n\nexport const isGlobPatternPath = (path: string): boolean => {\n // https://regex101.com/r/IBy7HS/1\n const globPattern = /^(?:\\/[^/*?[\\]{}]+)*\\/\\*$/;\n return globPattern.test(path);\n};\n\nexport * from './exceeds-max-page-depth.js';\nexport * from './is-top-page.js';\n"],"names":["isTopPage","_isTopPage","isUsersTopPage","path","isPermalink","pageIdStr","isValidObjectId","isUsersHomepage","isUsersProtectedPages","isMovablePage","isUserPage","isTrashTopPage","isTrashPage","isSharedPage","restrictedPatternsToCreate","isCreatablePage","pattern","exceedsMaxPageDepth","userHomepagePath","user","convertToNewAffiliationPath","oldPath","newPath","childPath","pathRegExp","encodeSpaces","generateEditorPath","paths","joinedPath","isInDescendantArea","areaPath","prefix","lowerCasedPath","omitDuplicateAreaPathFromPaths","uniquePaths","p","omitDuplicateAreaPageFromPages","pages","page","isEitherOfPathAreaOverlap","path1","path2","path1WithSlash","addTrailingSlash","path2WithSlash","path1Area","path2Area","isPathAreaOverlap","pathToTest","pathToBeTested","pathWithSlash","canMoveByPath","fromPath","toPath","hasSlash","str","getUsernameByPath","username","match","isGlobPatternPath"],"mappings":"6QAKaA,EAAYC,EAAAA,UAQZC,EAAkBC,GACtBA,IAAS,QAOLC,EAAeD,GAA0B,CACpD,MAAME,EAAYF,EAAK,UAAU,CAAC,EAClC,OAAOG,EAAAA,gBAAgBD,CAAS,CAClC,EAMaE,EAAmBJ,GAE1B,EAAAA,EAAK,MAAM,iBAAiB,EAUrBK,EAAyBL,GAC7BD,EAAeC,CAAI,GAAKI,EAAgBJ,CAAI,EAOxCM,EAAiBN,GACrB,CAACH,EAAUG,CAAI,GAAK,CAACK,EAAsBL,CAAI,EAO3CO,EAAcP,GAErB,EAAAA,EAAK,MAAM,eAAe,EAWnBQ,EAAkBR,GACtBA,IAAS,SAOLS,EAAeT,GAEtB,EAAAA,EAAK,MAAM,kBAAkB,EAWtBU,EAAgBV,GAEvB,EAAAA,EAAK,MAAM,kBAAkB,EAO7BW,EAA4C,CAChD,yBACA,WACA,YACA,mBACA,qBACA,SACA,SACA,WACA,SACA,WACA,cACA,KACA,mDACA,yGACA,sBACF,EAEaC,EAAmBZ,GAE5B,CAACW,EAA2B,KAAME,GAAYb,EAAK,MAAMa,CAAO,CAAC,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GAAID,IAAUC,EACZ,MAAO,GAGT,MAAMC,EAAiBC,EAAAA,iBAAiBH,CAAK,EACvCI,EAAiBD,EAAAA,iBAAiBF,CAAK,EAEvCI,EAAY,IAAI,OAAO,IAAI,OAAO,OAAOH,CAAc,CAAC,GAAI,GAAG,EAC/DI,EAAY,IAAI,OAAO,IAAI,OAAO,OAAOF,CAAc,CAAC,GAAI,GAAG,EAErE,MAAI,GAAAC,EAAU,KAAKJ,CAAK,GAAKK,EAAU,KAAKN,CAAK,EAKnD,EASaO,EAAoB,CAC/BC,EACAC,IACY,CACZ,GAAID,IAAeC,EACjB,MAAO,GAGT,MAAMC,EAAgBP,EAAAA,iBAAiBK,CAAU,EAGjD,MAAI,EADmB,IAAI,OAAO,IAAI,OAAO,OAAOE,CAAa,CAAC,GAAI,GAAG,EACtD,KAAKD,CAAc,CAKxC,EAQaE,EAAgB,CAACC,EAAkBC,IACvC,CAACN,EAAkBK,EAAUC,CAAM,EAM/BC,EAAYC,GAChBA,EAAI,SAAS,GAAG,EAQZC,EAAqBrD,GAAgC,CAChE,IAAIsD,EAA0B,KAE9B,MAAMC,EAAQvD,EAAK,MAAM,qBAAqB,EAC9C,OAAIuD,IACFD,EAAWC,EAAM,CAAC,GAGbD,CACT,EAEaE,EAAqBxD,GAEZ,4BACD,KAAKA,CAAI"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { isValidObjectId as
|
|
2
|
-
import { addTrailingSlash as
|
|
3
|
-
import { exceedsMaxPageDepth as
|
|
4
|
-
import { isTopPage as
|
|
1
|
+
import { isValidObjectId as c } from "../objectid-utils.js";
|
|
2
|
+
import { addTrailingSlash as a } from "../path-utils.js";
|
|
3
|
+
import { exceedsMaxPageDepth as u } from "./exceeds-max-page-depth.js";
|
|
4
|
+
import { isTopPage as h } from "./is-top-page.js";
|
|
5
5
|
import { generateChildrenRegExp as k } from "./generate-children-regexp.js";
|
|
6
|
-
const l =
|
|
6
|
+
const l = h, p = (e) => e === "/user", A = (e) => {
|
|
7
7
|
const t = e.substring(1);
|
|
8
|
-
return
|
|
9
|
-
},
|
|
8
|
+
return c(t);
|
|
9
|
+
}, g = (e) => !!e.match(/^\/user\/[^/]+$/), m = (e) => p(e) || g(e), R = (e) => !l(e) && !m(e), T = (e) => !!e.match(/^\/user\/.*?$/), v = (e) => e === "/trash", S = (e) => !!e.match(/^\/trash(\/.*)?$/), b = (e) => !!e.match(/^\/share(\/.*)?$/), f = [
|
|
10
10
|
/\^|\$|\*|\+|#|<|>|%|\?/,
|
|
11
11
|
/^\/-\/.*/,
|
|
12
12
|
/^\/_r\/.*/,
|
|
@@ -29,68 +29,69 @@ const l = u, p = (e) => e === "/user", w = (e) => {
|
|
|
29
29
|
/^\/(installer|register|login|logout|admin|me|files|trash|paste|comments|tags|share|attachment)(\/.*|$)/,
|
|
30
30
|
/^\/user(?:\/[^/]+)?$/
|
|
31
31
|
// https://regex101.com/r/9Eh2S1/1
|
|
32
|
-
],
|
|
32
|
+
], P = (e) => !f.some((t) => e.match(t)) && !u(e), y = (e) => (e == null ? void 0 : e.username) == null ? "" : `/user/${e.username}`, C = (e, t, r) => {
|
|
33
33
|
if (t == null)
|
|
34
34
|
throw new Error("Please input the new page path");
|
|
35
35
|
const s = new RegExp(`^${RegExp.escape(e)}`, "i");
|
|
36
36
|
return r.replace(s, t);
|
|
37
|
-
},
|
|
37
|
+
}, U = (e) => {
|
|
38
38
|
if (e != null)
|
|
39
39
|
return e.replace(/ /g, "%20").replace(/\u3000/g, "%E3%80%80");
|
|
40
|
-
},
|
|
40
|
+
}, I = (...e) => {
|
|
41
41
|
const t = [...e].join("/");
|
|
42
|
-
if (!
|
|
42
|
+
if (!P(t))
|
|
43
43
|
throw new Error("Invalid characters on path");
|
|
44
44
|
try {
|
|
45
45
|
return `${new URL(t, "https://dummy").pathname}#edit`;
|
|
46
46
|
} catch {
|
|
47
47
|
throw new Error("Invalid path format");
|
|
48
48
|
}
|
|
49
|
+
}, n = (e, t) => {
|
|
50
|
+
const r = `${t}/`.toLowerCase(), s = e.toLowerCase();
|
|
51
|
+
return s.length > r.length && s.startsWith(r);
|
|
49
52
|
}, _ = (e) => {
|
|
50
53
|
const t = Array.from(new Set(e));
|
|
51
|
-
return t.filter((r) => !
|
|
52
|
-
},
|
|
53
|
-
(s) => new RegExp(`^${s.path}\\/.+`, "i").test(t.path)
|
|
54
|
-
)), O = (e, t) => {
|
|
54
|
+
return t.filter((r) => !t.some((s) => n(r, s)));
|
|
55
|
+
}, D = (e) => e.filter((t) => !e.some((r) => n(t.path, r.path))), O = (e, t) => {
|
|
55
56
|
if (e === t)
|
|
56
57
|
return !0;
|
|
57
|
-
const r =
|
|
58
|
-
return !!(
|
|
59
|
-
},
|
|
58
|
+
const r = a(e), s = a(t), o = new RegExp(`^${RegExp.escape(r)}`, "i"), i = new RegExp(`^${RegExp.escape(s)}`, "i");
|
|
59
|
+
return !!(o.test(t) || i.test(e));
|
|
60
|
+
}, d = (e, t) => {
|
|
60
61
|
if (e === t)
|
|
61
62
|
return !0;
|
|
62
|
-
const r =
|
|
63
|
+
const r = a(e);
|
|
63
64
|
return !!new RegExp(`^${RegExp.escape(r)}`, "i").test(t);
|
|
64
|
-
},
|
|
65
|
+
}, W = (e, t) => !d(e, t), j = (e) => e.includes("/"), L = (e) => {
|
|
65
66
|
let t = null;
|
|
66
67
|
const r = e.match(/^\/user\/([^/]+)\/?/);
|
|
67
68
|
return r && (t = r[1]), t;
|
|
68
|
-
},
|
|
69
|
+
}, M = (e) => /^(?:\/[^/*?[\]{}]+)*\/\*$/.test(e);
|
|
69
70
|
export {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
W as canMoveByPath,
|
|
72
|
+
C as convertToNewAffiliationPath,
|
|
73
|
+
U as encodeSpaces,
|
|
74
|
+
u as exceedsMaxPageDepth,
|
|
74
75
|
k as generateChildrenRegExp,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
I as generateEditorPath,
|
|
77
|
+
L as getUsernameByPath,
|
|
78
|
+
j as hasSlash,
|
|
79
|
+
P as isCreatablePage,
|
|
79
80
|
O as isEitherOfPathAreaOverlap,
|
|
80
|
-
|
|
81
|
+
M as isGlobPatternPath,
|
|
81
82
|
R as isMovablePage,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
d as isPathAreaOverlap,
|
|
84
|
+
A as isPermalink,
|
|
85
|
+
b as isSharedPage,
|
|
85
86
|
l as isTopPage,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
S as isTrashPage,
|
|
88
|
+
v as isTrashTopPage,
|
|
89
|
+
T as isUserPage,
|
|
90
|
+
g as isUsersHomepage,
|
|
91
|
+
m as isUsersProtectedPages,
|
|
91
92
|
p as isUsersTopPage,
|
|
92
|
-
|
|
93
|
+
D as omitDuplicateAreaPageFromPages,
|
|
93
94
|
_ as omitDuplicateAreaPathFromPaths,
|
|
94
|
-
|
|
95
|
+
y as userHomepagePath
|
|
95
96
|
};
|
|
96
97
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/page-path-utils/index.ts"],"sourcesContent":["import { isValidObjectId } from '../objectid-utils.js';\nimport { addTrailingSlash } from '../path-utils.js';\nimport { exceedsMaxPageDepth } from './exceeds-max-page-depth.js';\nimport { isTopPage as _isTopPage } from './is-top-page.js';\n\nexport const isTopPage = _isTopPage;\n\nexport * from './generate-children-regexp.js';\n\n/**\n * Whether path is the top page of users\n * @param path\n */\nexport const isUsersTopPage = (path: string): boolean => {\n return path === '/user';\n};\n\n/**\n * Whether the path is permalink\n * @param path\n */\nexport const isPermalink = (path: string): boolean => {\n const pageIdStr = path.substring(1);\n return isValidObjectId(pageIdStr);\n};\n\n/**\n * Whether path is user's homepage\n * @param path\n */\nexport const isUsersHomepage = (path: string): boolean => {\n // https://regex101.com/r/utVQct/1\n if (path.match(/^\\/user\\/[^/]+$/)) {\n return true;\n }\n return false;\n};\n\n/**\n * Whether path is the protected pages for systems\n * @param path\n */\nexport const isUsersProtectedPages = (path: string): boolean => {\n return isUsersTopPage(path) || isUsersHomepage(path);\n};\n\n/**\n * Whether path is movable\n * @param path\n */\nexport const isMovablePage = (path: string): boolean => {\n return !isTopPage(path) && !isUsersProtectedPages(path);\n};\n\n/**\n * Whether path belongs to the user page\n * @param path\n */\nexport const isUserPage = (path: string): boolean => {\n // https://regex101.com/r/MwifLR/1\n if (path.match(/^\\/user\\/.*?$/)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Whether path is the top page of users\n * @param path\n */\nexport const isTrashTopPage = (path: string): boolean => {\n return path === '/trash';\n};\n\n/**\n * Whether path belongs to the trash page\n * @param path\n */\nexport const isTrashPage = (path: string): boolean => {\n // https://regex101.com/r/BSDdRr/1\n if (path.match(/^\\/trash(\\/.*)?$/)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Whether path belongs to the shared page\n * @param path\n */\nexport const isSharedPage = (path: string): boolean => {\n // https://regex101.com/r/ZjdOiB/1\n if (path.match(/^\\/share(\\/.*)?$/)) {\n return true;\n }\n\n return false;\n};\n\nconst restrictedPatternsToCreate: Array<RegExp> = [\n /\\^|\\$|\\*|\\+|#|<|>|%|\\?/,\n /^\\/-\\/.*/,\n /^\\/_r\\/.*/,\n /^\\/_apix?(\\/.*)?/,\n /^\\/?https?:\\/\\/.+$/, // avoid miss in renaming\n /\\/{2,}/, // avoid miss in renaming\n /\\s\\/\\s/, // avoid miss in renaming\n /.\\/edit$/,\n /.\\.md$/,\n /^(\\.\\.)$/, // see: https://github.com/growilabs/growi/issues/3582\n /(\\/\\.\\.)\\/?/, // see: https://github.com/growilabs/growi/issues/3582\n /\\\\/, // see: https://github.com/growilabs/growi/issues/7241\n /^\\/(_search|_private-legacy-pages|_news)(\\/.*|$)/,\n /^\\/(installer|register|login|logout|admin|me|files|trash|paste|comments|tags|share|attachment)(\\/.*|$)/,\n /^\\/user(?:\\/[^/]+)?$/, // https://regex101.com/r/9Eh2S1/1\n];\n\nexport const isCreatablePage = (path: string): boolean => {\n return (\n !restrictedPatternsToCreate.some((pattern) => path.match(pattern)) &&\n !exceedsMaxPageDepth(path)\n );\n};\n\n/**\n * return user's homepage path\n * @param user\n */\nexport const userHomepagePath = (\n user: { username: string } | null | undefined,\n): string => {\n if (user?.username == null) {\n return '';\n }\n return `/user/${user.username}`;\n};\n\n/**\n * return user path\n * @param parentPath\n * @param childPath\n * @param newPath\n */\nexport const convertToNewAffiliationPath = (\n oldPath: string,\n newPath: string,\n childPath: string,\n): string => {\n if (newPath == null) {\n throw new Error('Please input the new page path');\n }\n const pathRegExp = new RegExp(`^${RegExp.escape(oldPath)}`, 'i');\n return childPath.replace(pathRegExp, newPath);\n};\n\n/**\n * Encode SPACE and IDEOGRAPHIC SPACE\n * @param {string} path\n * @returns {string}\n */\nexport const encodeSpaces = (path?: string): string | undefined => {\n if (path == null) {\n return undefined;\n }\n\n // Encode SPACE and IDEOGRAPHIC SPACE\n return path.replace(/ /g, '%20').replace(/\\u3000/g, '%E3%80%80');\n};\n\n/**\n * Generate editor path\n * @param {string} paths\n * @returns {string}\n */\nexport const generateEditorPath = (...paths: string[]): string => {\n const joinedPath = [...paths].join('/');\n\n if (!isCreatablePage(joinedPath)) {\n throw new Error('Invalid characters on path');\n }\n\n try {\n const url = new URL(joinedPath, 'https://dummy');\n return `${url.pathname}#edit`;\n } catch {\n throw new Error('Invalid path format');\n }\n};\n\n/**\n * return paths without duplicate area of regexp /^${path}\\/.+/i\n * ex. expect(omitDuplicateAreaPathFromPaths(['/A', '/A/B', '/A/B/C'])).toStrictEqual(['/A'])\n * @param paths paths to be tested\n * @returns omitted paths\n */\nexport const omitDuplicateAreaPathFromPaths = (paths: string[]): string[] => {\n const uniquePaths = Array.from(new Set(paths));\n return uniquePaths.filter((path) => {\n const isDuplicate =\n uniquePaths.filter((p) => new RegExp(`^${p}\\\\/.+`, 'i').test(path))\n .length > 0;\n\n return !isDuplicate;\n });\n};\n\n/**\n * return pages with path without duplicate area of regexp /^${path}\\/.+/i\n * if the pages' path are the same, it will NOT omit any of them since the other attributes will not be the same\n * @param paths paths to be tested\n * @returns omitted paths\n */\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const omitDuplicateAreaPageFromPages = (pages: any[]): any[] => {\n return pages.filter((page) => {\n const isDuplicate = pages.some((p) =>\n new RegExp(`^${p.path}\\\\/.+`, 'i').test(page.path),\n );\n\n return !isDuplicate;\n });\n};\n\n/**\n * Check if the area of either path1 or path2 includes the area of the other path\n * The area of path is the same as /^\\/hoge\\//i\n * @param pathToTest string\n * @param pathToBeTested string\n * @returns boolean\n */\nexport const isEitherOfPathAreaOverlap = (\n path1: string,\n path2: string,\n): boolean => {\n if (path1 === path2) {\n return true;\n }\n\n const path1WithSlash = addTrailingSlash(path1);\n const path2WithSlash = addTrailingSlash(path2);\n\n const path1Area = new RegExp(`^${RegExp.escape(path1WithSlash)}`, 'i');\n const path2Area = new RegExp(`^${RegExp.escape(path2WithSlash)}`, 'i');\n\n if (path1Area.test(path2) || path2Area.test(path1)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Check if the area of pathToTest includes the area of pathToBeTested\n * The area of path is the same as /^\\/hoge\\//i\n * @param pathToTest string\n * @param pathToBeTested string\n * @returns boolean\n */\nexport const isPathAreaOverlap = (\n pathToTest: string,\n pathToBeTested: string,\n): boolean => {\n if (pathToTest === pathToBeTested) {\n return true;\n }\n\n const pathWithSlash = addTrailingSlash(pathToTest);\n\n const pathAreaToTest = new RegExp(`^${RegExp.escape(pathWithSlash)}`, 'i');\n if (pathAreaToTest.test(pathToBeTested)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Determine whether can move by fromPath and toPath\n * @param fromPath string\n * @param toPath string\n * @returns boolean\n */\nexport const canMoveByPath = (fromPath: string, toPath: string): boolean => {\n return !isPathAreaOverlap(fromPath, toPath);\n};\n\n/**\n * check if string has '/' in it\n */\nexport const hasSlash = (str: string): boolean => {\n return str.includes('/');\n};\n\n/**\n * Get username from user page path\n * @param path string\n * @returns string | null\n */\nexport const getUsernameByPath = (path: string): string | null => {\n let username: string | null = null;\n // https://regex101.com/r/qj4SfD/1\n const match = path.match(/^\\/user\\/([^/]+)\\/?/);\n if (match) {\n username = match[1];\n }\n\n return username;\n};\n\nexport const isGlobPatternPath = (path: string): boolean => {\n // https://regex101.com/r/IBy7HS/1\n const globPattern = /^(?:\\/[^/*?[\\]{}]+)*\\/\\*$/;\n return globPattern.test(path);\n};\n\nexport * from './exceeds-max-page-depth.js';\nexport * from './is-top-page.js';\n"],"names":["isTopPage","_isTopPage","isUsersTopPage","path","isPermalink","pageIdStr","isValidObjectId","isUsersHomepage","isUsersProtectedPages","isMovablePage","isUserPage","isTrashTopPage","isTrashPage","isSharedPage","restrictedPatternsToCreate","isCreatablePage","pattern","exceedsMaxPageDepth","userHomepagePath","user","convertToNewAffiliationPath","oldPath","newPath","childPath","pathRegExp","encodeSpaces","generateEditorPath","paths","joinedPath","omitDuplicateAreaPathFromPaths","uniquePaths","p","omitDuplicateAreaPageFromPages","pages","page","isEitherOfPathAreaOverlap","path1","path2","path1WithSlash","addTrailingSlash","path2WithSlash","path1Area","path2Area","isPathAreaOverlap","pathToTest","pathToBeTested","pathWithSlash","canMoveByPath","fromPath","toPath","hasSlash","str","getUsernameByPath","username","match","isGlobPatternPath"],"mappings":";;;;;AAKO,MAAMA,IAAYC,GAQZC,IAAiB,CAACC,MACtBA,MAAS,SAOLC,IAAc,CAACD,MAA0B;AACpD,QAAME,IAAYF,EAAK,UAAU,CAAC;AAClC,SAAOG,EAAgBD,CAAS;AAClC,GAMaE,IAAkB,CAACJ,MAE1B,EAAAA,EAAK,MAAM,iBAAiB,GAUrBK,IAAwB,CAACL,MAC7BD,EAAeC,CAAI,KAAKI,EAAgBJ,CAAI,GAOxCM,IAAgB,CAACN,MACrB,CAACH,EAAUG,CA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C,EAAM,CAAC,IAGbD;AACT,GAEaE,IAAoB,CAACpD,MAEZ,4BACD,KAAKA,CAAI;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/page-path-utils/index.ts"],"sourcesContent":["import { isValidObjectId } from '../objectid-utils.js';\nimport { addTrailingSlash } from '../path-utils.js';\nimport { exceedsMaxPageDepth } from './exceeds-max-page-depth.js';\nimport { isTopPage as _isTopPage } from './is-top-page.js';\n\nexport const isTopPage = _isTopPage;\n\nexport * from './generate-children-regexp.js';\n\n/**\n * Whether path is the top page of users\n * @param path\n */\nexport const isUsersTopPage = (path: string): boolean => {\n return path === '/user';\n};\n\n/**\n * Whether the path is permalink\n * @param path\n */\nexport const isPermalink = (path: string): boolean => {\n const pageIdStr = path.substring(1);\n return isValidObjectId(pageIdStr);\n};\n\n/**\n * Whether path is user's homepage\n * @param path\n */\nexport const isUsersHomepage = (path: string): boolean => {\n // https://regex101.com/r/utVQct/1\n if (path.match(/^\\/user\\/[^/]+$/)) {\n return true;\n }\n return false;\n};\n\n/**\n * Whether path is the protected pages for systems\n * @param path\n */\nexport const isUsersProtectedPages = (path: string): boolean => {\n return isUsersTopPage(path) || isUsersHomepage(path);\n};\n\n/**\n * Whether path is movable\n * @param path\n */\nexport const isMovablePage = (path: string): boolean => {\n return !isTopPage(path) && !isUsersProtectedPages(path);\n};\n\n/**\n * Whether path belongs to the user page\n * @param path\n */\nexport const isUserPage = (path: string): boolean => {\n // https://regex101.com/r/MwifLR/1\n if (path.match(/^\\/user\\/.*?$/)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Whether path is the top page of users\n * @param path\n */\nexport const isTrashTopPage = (path: string): boolean => {\n return path === '/trash';\n};\n\n/**\n * Whether path belongs to the trash page\n * @param path\n */\nexport const isTrashPage = (path: string): boolean => {\n // https://regex101.com/r/BSDdRr/1\n if (path.match(/^\\/trash(\\/.*)?$/)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Whether path belongs to the shared page\n * @param path\n */\nexport const isSharedPage = (path: string): boolean => {\n // https://regex101.com/r/ZjdOiB/1\n if (path.match(/^\\/share(\\/.*)?$/)) {\n return true;\n }\n\n return false;\n};\n\nconst restrictedPatternsToCreate: Array<RegExp> = [\n /\\^|\\$|\\*|\\+|#|<|>|%|\\?/,\n /^\\/-\\/.*/,\n /^\\/_r\\/.*/,\n /^\\/_apix?(\\/.*)?/,\n /^\\/?https?:\\/\\/.+$/, // avoid miss in renaming\n /\\/{2,}/, // avoid miss in renaming\n /\\s\\/\\s/, // avoid miss in renaming\n /.\\/edit$/,\n /.\\.md$/,\n /^(\\.\\.)$/, // see: https://github.com/growilabs/growi/issues/3582\n /(\\/\\.\\.)\\/?/, // see: https://github.com/growilabs/growi/issues/3582\n /\\\\/, // see: https://github.com/growilabs/growi/issues/7241\n /^\\/(_search|_private-legacy-pages|_news)(\\/.*|$)/,\n /^\\/(installer|register|login|logout|admin|me|files|trash|paste|comments|tags|share|attachment)(\\/.*|$)/,\n /^\\/user(?:\\/[^/]+)?$/, // https://regex101.com/r/9Eh2S1/1\n];\n\nexport const isCreatablePage = (path: string): boolean => {\n return (\n !restrictedPatternsToCreate.some((pattern) => path.match(pattern)) &&\n !exceedsMaxPageDepth(path)\n );\n};\n\n/**\n * return user's homepage path\n * @param user\n */\nexport const userHomepagePath = (\n user: { username: string } | null | undefined,\n): string => {\n if (user?.username == null) {\n return '';\n }\n return `/user/${user.username}`;\n};\n\n/**\n * return user path\n * @param parentPath\n * @param childPath\n * @param newPath\n */\nexport const convertToNewAffiliationPath = (\n oldPath: string,\n newPath: string,\n childPath: string,\n): string => {\n if (newPath == null) {\n throw new Error('Please input the new page path');\n }\n const pathRegExp = new RegExp(`^${RegExp.escape(oldPath)}`, 'i');\n return childPath.replace(pathRegExp, newPath);\n};\n\n/**\n * Encode SPACE and IDEOGRAPHIC SPACE\n * @param {string} path\n * @returns {string}\n */\nexport const encodeSpaces = (path?: string): string | undefined => {\n if (path == null) {\n return undefined;\n }\n\n // Encode SPACE and IDEOGRAPHIC SPACE\n return path.replace(/ /g, '%20').replace(/\\u3000/g, '%E3%80%80');\n};\n\n/**\n * Generate editor path\n * @param {string} paths\n * @returns {string}\n */\nexport const generateEditorPath = (...paths: string[]): string => {\n const joinedPath = [...paths].join('/');\n\n if (!isCreatablePage(joinedPath)) {\n throw new Error('Invalid characters on path');\n }\n\n try {\n const url = new URL(joinedPath, 'https://dummy');\n return `${url.pathname}#edit`;\n } catch {\n throw new Error('Invalid path format');\n }\n};\n\n// Same result as /^${areaPath}\\/.+/i for ordinary paths, with areaPath matched literally\nconst isInDescendantArea = (path: string, areaPath: string): boolean => {\n const prefix = `${areaPath}/`.toLowerCase();\n const lowerCasedPath = path.toLowerCase();\n return (\n lowerCasedPath.length > prefix.length && lowerCasedPath.startsWith(prefix)\n );\n};\n\n/**\n * return paths without duplicate area of regexp /^${path}\\/.+/i\n * ex. expect(omitDuplicateAreaPathFromPaths(['/A', '/A/B', '/A/B/C'])).toStrictEqual(['/A'])\n * @param paths paths to be tested\n * @returns omitted paths\n */\nexport const omitDuplicateAreaPathFromPaths = (paths: string[]): string[] => {\n const uniquePaths = Array.from(new Set(paths));\n return uniquePaths.filter((path) => {\n return !uniquePaths.some((p) => isInDescendantArea(path, p));\n });\n};\n\n/**\n * return pages with path without duplicate area of regexp /^${path}\\/.+/i\n * if the pages' path are the same, it will NOT omit any of them since the other attributes will not be the same\n * @param paths paths to be tested\n * @returns omitted paths\n */\n// biome-ignore lint/suspicious/noExplicitAny: ignore\nexport const omitDuplicateAreaPageFromPages = (pages: any[]): any[] => {\n return pages.filter((page) => {\n return !pages.some((p) => isInDescendantArea(page.path, p.path));\n });\n};\n\n/**\n * Check if the area of either path1 or path2 includes the area of the other path\n * The area of path is the same as /^\\/hoge\\//i\n * @param pathToTest string\n * @param pathToBeTested string\n * @returns boolean\n */\nexport const isEitherOfPathAreaOverlap = (\n path1: string,\n path2: string,\n): boolean => {\n if (path1 === path2) {\n return true;\n }\n\n const path1WithSlash = addTrailingSlash(path1);\n const path2WithSlash = addTrailingSlash(path2);\n\n const path1Area = new RegExp(`^${RegExp.escape(path1WithSlash)}`, 'i');\n const path2Area = new RegExp(`^${RegExp.escape(path2WithSlash)}`, 'i');\n\n if (path1Area.test(path2) || path2Area.test(path1)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Check if the area of pathToTest includes the area of pathToBeTested\n * The area of path is the same as /^\\/hoge\\//i\n * @param pathToTest string\n * @param pathToBeTested string\n * @returns boolean\n */\nexport const isPathAreaOverlap = (\n pathToTest: string,\n pathToBeTested: string,\n): boolean => {\n if (pathToTest === pathToBeTested) {\n return true;\n }\n\n const pathWithSlash = addTrailingSlash(pathToTest);\n\n const pathAreaToTest = new RegExp(`^${RegExp.escape(pathWithSlash)}`, 'i');\n if (pathAreaToTest.test(pathToBeTested)) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Determine whether can move by fromPath and toPath\n * @param fromPath string\n * @param toPath string\n * @returns boolean\n */\nexport const canMoveByPath = (fromPath: string, toPath: string): boolean => {\n return !isPathAreaOverlap(fromPath, toPath);\n};\n\n/**\n * check if string has '/' in it\n */\nexport const hasSlash = (str: string): boolean => {\n return str.includes('/');\n};\n\n/**\n * Get username from user page path\n * @param path string\n * @returns string | null\n */\nexport const getUsernameByPath = (path: string): string | null => {\n let username: string | null = null;\n // https://regex101.com/r/qj4SfD/1\n const match = path.match(/^\\/user\\/([^/]+)\\/?/);\n if (match) {\n username = match[1];\n }\n\n return username;\n};\n\nexport const isGlobPatternPath = (path: string): boolean => {\n // https://regex101.com/r/IBy7HS/1\n const globPattern = /^(?:\\/[^/*?[\\]{}]+)*\\/\\*$/;\n return globPattern.test(path);\n};\n\nexport * from './exceeds-max-page-depth.js';\nexport * from './is-top-page.js';\n"],"names":["isTopPage","_isTopPage","isUsersTopPage","path","isPermalink","pageIdStr","isValidObjectId","isUsersHomepage","isUsersProtectedPages","isMovablePage","isUserPage","isTrashTopPage","isTrashPage","isSharedPage","restrictedPatternsToCreate","isCreatablePage","pattern","exceedsMaxPageDepth","userHomepagePath","user","convertToNewAffiliationPath","oldPath","newPath","childPath","pathRegExp","encodeSpaces","generateEditorPath","paths","joinedPath","isInDescendantArea","areaPath","prefix","lowerCasedPath","omitDuplicateAreaPathFromPaths","uniquePaths","p","omitDuplicateAreaPageFromPages","pages","page","isEitherOfPathAreaOverlap","path1","path2","path1WithSlash","addTrailingSlash","path2WithSlash","path1Area","path2Area","isPathAreaOverlap","pathToTest","pathToBeTested","pathWithSlash","canMoveByPath","fromPath","toPath","hasSlash","str","getUsernameByPath","username","match","isGlobPatternPath"],"mappings":";;;;;AAKO,MAAMA,IAAYC,GAQZC,IAAiB,CAACC,MACtBA,MAAS,SAOLC,IAAc,CAACD,MAA0B;AACpD,QAAME,IAAYF,EAAK,UAAU,CAAC;AAClC,SAAOG,EAAgBD,CAAS;AAClC,GAMaE,IAAkB,CAACJ,MAE1B,EAAAA,EAAK,MAAM,iBAAiB,GAUrBK,IAAwB,CAACL,MAC7BD,EAAeC,CAAI,KAAKI,EAAgBJ,CAAI,GAOxCM,IAAgB,CAACN,MACrB,CAACH,EAAUG,CAAI,KAAK,CAACK,EAAsBL,CAAI,GAO3CO,IAAa,CAACP,MAErB,EAAAA,EAAK,MAAM,eAAe,GAWnBQ,IAAiB,CAACR,MACtBA,MAAS,UAOLS,IAAc,CAACT,MAEtB,EAAAA,EAAK,MAAM,kBAAkB,GAWtBU,IAAe,CAACV,MAEvB,EAAAA,EAAK,MAAM,kBAAkB,GAO7BW,IAA4C;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AACF,GAEaC,IAAkB,CAACZ,MAE5B,CAACW,EAA2B,KAAK,CAACE,MAAYb,EAAK,MAAM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