From 0ec620fcf01eacbbf72ad18d24500ac4f01e8b35 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Thu, 21 Jan 2021 21:42:08 +0100 Subject: [PATCH] Render baseurl without trailing slash The webapp expects it like this currently, because the url is only a string. --- .../common/src/main/scala/docspell/common/LenientUri.scala | 6 ++++++ .../src/main/scala/docspell/restserver/webapp/Flags.scala | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/common/src/main/scala/docspell/common/LenientUri.scala b/modules/common/src/main/scala/docspell/common/LenientUri.scala index 600d0a61..ca1b5069 100644 --- a/modules/common/src/main/scala/docspell/common/LenientUri.scala +++ b/modules/common/src/main/scala/docspell/common/LenientUri.scala @@ -49,6 +49,12 @@ case class LenientUri( def withFragment(f: String): LenientUri = copy(fragment = Some(f)) + def rootPathToEmpty: LenientUri = + path match { + case LenientUri.RootPath => copy(path = LenientUri.EmptyPath) + case _ => this + } + def toJavaUrl: Either[String, URL] = Either.catchNonFatal(new URL(asString)).left.map(_.getMessage) diff --git a/modules/restserver/src/main/scala/docspell/restserver/webapp/Flags.scala b/modules/restserver/src/main/scala/docspell/restserver/webapp/Flags.scala index 3e36359b..3966445e 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/webapp/Flags.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/webapp/Flags.scala @@ -36,8 +36,8 @@ object Flags { ) private def getBaseUrl(cfg: Config): String = - if (cfg.baseUrl.isLocal) cfg.baseUrl.path.asString - else cfg.baseUrl.asString + if (cfg.baseUrl.isLocal) cfg.baseUrl.rootPathToEmpty.path.asString + else cfg.baseUrl.rootPathToEmpty.asString implicit val jsonEncoder: Encoder[Flags] = deriveEncoder[Flags]