Refactor and regroup urlHelpers utils (#6462)
* fix: refactor urlHelpers * fix: move to /plugins/slack/shared * fix: remove .babelrc * fix: remove Outline class * fix: Slack -> SlackUtils * fix: UrlHelper class
This commit is contained in:
@@ -34,9 +34,9 @@ import {
|
||||
import isUUID from "validator/lib/isUUID";
|
||||
import type { CollectionSort } from "@shared/types";
|
||||
import { CollectionPermission, NavigationNode } from "@shared/types";
|
||||
import { UrlHelper } from "@shared/utils/UrlHelper";
|
||||
import { sortNavigationNodes } from "@shared/utils/collections";
|
||||
import slugify from "@shared/utils/slugify";
|
||||
import { SLUG_URL_REGEX } from "@shared/utils/urlHelpers";
|
||||
import { CollectionValidation } from "@shared/validations";
|
||||
import { ValidationError } from "@server/errors";
|
||||
import Document from "./Document";
|
||||
@@ -394,7 +394,7 @@ class Collection extends ParanoidModel<
|
||||
});
|
||||
}
|
||||
|
||||
const match = id.match(SLUG_URL_REGEX);
|
||||
const match = id.match(UrlHelper.SLUG_URL_REGEX);
|
||||
if (match) {
|
||||
return this.findOne({
|
||||
where: {
|
||||
|
||||
@@ -47,9 +47,9 @@ import type {
|
||||
ProsemirrorData,
|
||||
SourceMetadata,
|
||||
} from "@shared/types";
|
||||
import { UrlHelper } from "@shared/utils/UrlHelper";
|
||||
import getTasks from "@shared/utils/getTasks";
|
||||
import slugify from "@shared/utils/slugify";
|
||||
import { SLUG_URL_REGEX } from "@shared/utils/urlHelpers";
|
||||
import { DocumentValidation } from "@shared/validations";
|
||||
import { ValidationError } from "@server/errors";
|
||||
import Backlink from "./Backlink";
|
||||
@@ -611,7 +611,7 @@ class Document extends ParanoidModel<
|
||||
return document;
|
||||
}
|
||||
|
||||
const match = id.match(SLUG_URL_REGEX);
|
||||
const match = id.match(UrlHelper.SLUG_URL_REGEX);
|
||||
if (match) {
|
||||
const document = await scope.findOne({
|
||||
where: {
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
Unique,
|
||||
BeforeUpdate,
|
||||
} from "sequelize-typescript";
|
||||
import { SHARE_URL_SLUG_REGEX } from "@shared/utils/urlHelpers";
|
||||
import { UrlHelper } from "@shared/utils/UrlHelper";
|
||||
import env from "@server/env";
|
||||
import { ValidationError } from "@server/errors";
|
||||
import Collection from "./Collection";
|
||||
@@ -96,7 +96,7 @@ class Share extends IdModel<
|
||||
|
||||
@AllowNull
|
||||
@Is({
|
||||
args: SHARE_URL_SLUG_REGEX,
|
||||
args: UrlHelper.SHARE_URL_SLUG_REGEX,
|
||||
msg: "Must be only alphanumeric and dashes",
|
||||
})
|
||||
@Column
|
||||
|
||||
Reference in New Issue
Block a user