mirror of
https://github.com/outline/outline.git
synced 2026-11-21 21:44:30 +03:00
* fix: Validate API key scopes with Sequelize-level validators * test: Add API regression tests for duplicate OAuth redirect URIs * fix: Preserve wildcard scope and guard non-string redirect URIs --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
27 lines
773 B
TypeScript
27 lines
773 B
TypeScript
import isURL from "validator/lib/isURL";
|
|
import { addAttributeOptions } from "sequelize-typescript";
|
|
import env from "@server/env";
|
|
|
|
/**
|
|
* A decorator that validates that a string is a valid HTTP(S) url. A top-level
|
|
* domain is only required when cloud hosted, allowing self-hosted installations
|
|
* to use internal hostnames.
|
|
*/
|
|
export default function IsUrl(target: object, propertyName: string) {
|
|
return addAttributeOptions(target, propertyName, {
|
|
validate: {
|
|
validUrl(value: string) {
|
|
if (
|
|
!isURL(value, {
|
|
protocols: ["http", "https"],
|
|
require_protocol: true,
|
|
require_tld: env.isCloudHosted,
|
|
})
|
|
) {
|
|
throw new Error("Must be a valid url");
|
|
}
|
|
},
|
|
},
|
|
});
|
|
}
|