fix: remove subpath support for HD_BASE_URL

With this commit we drop the subpath support which results in the constraint that HedgeDoc must always run on the root of a domain. This makes a lot of things in testing, rendering and security much easier.

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-08-12 20:07:38 +02:00
parent 7401791ec8
commit dccd58f0c1
32 changed files with 111 additions and 116 deletions

View file

@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { MissingTrailingSlashError, WrongProtocolError } from './errors.js'
import { NoSubdirectoryAllowedError, WrongProtocolError } from './errors.js'
import { Optional } from '@mrdrogdrog/optional'
/**
@ -12,7 +12,7 @@ import { Optional } from '@mrdrogdrog/optional'
* @param {String | undefined} url the raw url
* @return An {@link Optional} that contains the parsed URL or is empty if the raw value isn't a valid URL
* @throws WrongProtocolError if the protocol of the URL isn't either http nor https
* @throws MissingTrailingSlashError if the URL has a path that doesn't end with a trailing slash
* @throws NoSubdirectoryAllowedError if the URL has a path that doesn't end with a trailing slash
*/
export function parseUrl(url: string | undefined): Optional<URL> {
return createOptionalUrl(url)
@ -21,8 +21,8 @@ export function parseUrl(url: string | undefined): Optional<URL> {
() => new WrongProtocolError()
)
.guard(
(value) => value.pathname.endsWith('/'),
() => new MissingTrailingSlashError()
(value) => value.pathname === '/',
() => new NoSubdirectoryAllowedError()
)
}