mirror of
https://github.com/outline/outline.git
synced 2026-11-26 23:50:14 +03:00
* Upgrade @typescript-eslint dependencies from v6.21.0 to v8.33.0 - Updated @typescript-eslint/eslint-plugin from ^6.21.0 to ^8.33.0 - Updated @typescript-eslint/parser from ^6.21.0 to ^8.33.0 - Tested linting functionality to ensure compatibility - This brings the latest TypeScript ESLint features and bug fixes * lint * tsc --------- Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com>
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
import isNil from "lodash/isNil";
|
|
import isUUID from "validator/lib/isUUID";
|
|
import { z } from "zod";
|
|
import { UrlHelper } from "@shared/utils/UrlHelper";
|
|
import { isUrl } from "@shared/utils/urls";
|
|
import { ValidateURL } from "@server/validation";
|
|
import { BaseSchema } from "../schema";
|
|
|
|
export const UrlsUnfurlSchema = BaseSchema.extend({
|
|
body: z
|
|
.object({
|
|
url: z
|
|
.string()
|
|
.url()
|
|
.refine(
|
|
(val) => {
|
|
try {
|
|
const url = new URL(val);
|
|
if (url.protocol === "mention:") {
|
|
return ValidateURL.isValidMentionUrl(val);
|
|
}
|
|
return isUrl(val);
|
|
} catch (_err) {
|
|
return false;
|
|
}
|
|
},
|
|
{ message: ValidateURL.message }
|
|
),
|
|
documentId: z
|
|
.string()
|
|
.optional()
|
|
.refine(
|
|
(val) =>
|
|
val ? isUUID(val) || UrlHelper.SLUG_URL_REGEX.test(val) : true,
|
|
{
|
|
message: "must be uuid or url slug",
|
|
}
|
|
),
|
|
})
|
|
.refine(
|
|
(val) =>
|
|
!(ValidateURL.isValidMentionUrl(val.url) && isNil(val.documentId)),
|
|
{ message: "documentId required" }
|
|
),
|
|
});
|
|
|
|
export type UrlsUnfurlReq = z.infer<typeof UrlsUnfurlSchema>;
|
|
|
|
export const UrlsCheckCnameSchema = BaseSchema.extend({
|
|
body: z.object({
|
|
hostname: z.string(),
|
|
}),
|
|
});
|
|
|
|
export type UrlsCheckCnameReq = z.infer<typeof UrlsCheckCnameSchema>;
|