mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
5610df5a26
* chore: Reduce no-explicit-any warnings in server directory Tightens types across test response bodies, decorator signatures, the TestServer wrapper, base class generics, and presenter Record types. Where any is genuinely load-bearing (Sequelize model generics, PropertyDescriptor decorator returns, plugin-registered template classes, Fix mixin), keeps any with a targeted eslint-disable plus reason rather than masking the constraint. Cuts server-only no-explicit-any warnings from 162 to 70. * fix: groups test asserts on first response instead of second Caught by Copilot review on the no-explicit-any cleanup. Also fixes the pre-existing getChangsetSkipped → getChangesetSkipped typo surfaced while reviewing nearby decorator code.
27 lines
626 B
TypeScript
27 lines
626 B
TypeScript
import { isURL } from "class-validator";
|
|
import { addAttributeOptions } from "sequelize-typescript";
|
|
|
|
/**
|
|
* A decorator that validates that a string is a url or relative path.
|
|
*/
|
|
export default function IsUrlOrRelativePath(
|
|
target: object,
|
|
propertyName: string
|
|
) {
|
|
return addAttributeOptions(target, propertyName, {
|
|
validate: {
|
|
validUrlOrPath(value: string) {
|
|
if (
|
|
value &&
|
|
!isURL(value, {
|
|
require_host: false,
|
|
require_protocol: false,
|
|
})
|
|
) {
|
|
throw new Error("Must be a URL or relative path");
|
|
}
|
|
},
|
|
},
|
|
});
|
|
}
|