|
@@ -11,38 +11,48 @@ export const isTopPage = (path: string): boolean => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Whether path belongs to the trash page
|
|
|
|
|
|
|
+ * Whether path is the top page of users
|
|
|
* @param path
|
|
* @param path
|
|
|
*/
|
|
*/
|
|
|
-export const isTrashPage = (path: string): boolean => {
|
|
|
|
|
- // https://regex101.com/r/BSDdRr/1
|
|
|
|
|
- if (path.match(/^\/trash(\/.*)?$/)) {
|
|
|
|
|
|
|
+export const isUsersTopPage = (path: string): boolean => {
|
|
|
|
|
+ return path === '/user';
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Whether path is user's home page
|
|
|
|
|
+ * @param path
|
|
|
|
|
+ */
|
|
|
|
|
+export const isUsersHomePage = (path: string): boolean => {
|
|
|
|
|
+ // https://regex101.com/r/utVQct/1
|
|
|
|
|
+ if (path.match(/^\/user\/[^/]+$/)) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return false;
|
|
return false;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Whether path belongs to the user page
|
|
|
|
|
|
|
+ * Whether path is the protected pages for systems
|
|
|
* @param path
|
|
* @param path
|
|
|
*/
|
|
*/
|
|
|
-export const isUserPage = (path: string): boolean => {
|
|
|
|
|
- // https://regex101.com/r/SxPejV/1
|
|
|
|
|
- if (path.match(/^\/user(\/.*)?$/)) {
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+export const isUsersProtectedPages = (path: string): boolean => {
|
|
|
|
|
+ return isUsersTopPage(path) || isUsersHomePage(path);
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * Whether path is movable
|
|
|
|
|
+ * @param path
|
|
|
|
|
+ */
|
|
|
|
|
+export const isMovablePage = (path: string): boolean => {
|
|
|
|
|
+ return !isTopPage(path) && !isUsersProtectedPages(path);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Whether path is right under the path '/user'
|
|
|
|
|
|
|
+ * Whether path belongs to the trash page
|
|
|
* @param path
|
|
* @param path
|
|
|
*/
|
|
*/
|
|
|
-export const isUserNamePage = (path: string): boolean => {
|
|
|
|
|
- // https://regex101.com/r/GUZntH/1
|
|
|
|
|
- if (path.match(/^\/user\/[^/]+$/)) {
|
|
|
|
|
|
|
+export const isTrashPage = (path: string): boolean => {
|
|
|
|
|
+ // https://regex101.com/r/BSDdRr/1
|
|
|
|
|
+ if (path.match(/^\/trash(\/.*)?$/)) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -62,13 +72,6 @@ export const isSharedPage = (path: string): boolean => {
|
|
|
return false;
|
|
return false;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const restrictedPatternsToDelete: Array<RegExp> = [
|
|
|
|
|
- /^\/user\/[^/]+$/, // user page
|
|
|
|
|
-];
|
|
|
|
|
-export const isDeletablePage = (path: string): boolean => {
|
|
|
|
|
- return !restrictedPatternsToDelete.some(pattern => path.match(pattern));
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
const restrictedPatternsToCreate: Array<RegExp> = [
|
|
const restrictedPatternsToCreate: Array<RegExp> = [
|
|
|
/\^|\$|\*|\+|#|%|\?/,
|
|
/\^|\$|\*|\+|#|%|\?/,
|
|
|
/^\/-\/.*/,
|
|
/^\/-\/.*/,
|