Skip to content

Home > @opengovsg/validators > RelUrlValidator > (constructor)

RelUrlValidator.(constructor) ​

Creates a new RelUrlValidator instance which only allows relative URLs.

Signature:

typescript
constructor(origin: string | URL);

Parameters ​

ParameterTypeDescription
originstring | URLThe base origin against which relative URLs will be resolved. Must be a valid absolute URL (e.g., 'https://example.com').

Exceptions ​

TypeError If the provided origin is not a valid URL.