File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
commons-core/src/main/scala/com/avsystem/commons
commons-jetty/src/main/scala/com/avsystem/commons/jetty/rest Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,12 @@ object SharedExtensions extends SharedExtensions {
187
187
private val RemovableLineBreak = " \\ n+" .r
188
188
189
189
class StringOps (private val str : String ) extends AnyVal {
190
+ /**
191
+ * Makes sure that `String` value is not `null` by replacing `null` with empty string.
192
+ */
193
+ def orEmpty : String =
194
+ if (str == null ) " " else str
195
+
190
196
def ensureSuffix (suffix : String ): String =
191
197
if (str.endsWith(suffix)) str else str + suffix
192
198
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ object RestServlet {
27
27
28
28
def readParameters (request : HttpServletRequest ): RestParameters = {
29
29
// can't use request.getPathInfo because it decodes the URL before we can split it
30
- val pathPrefix = request.getContextPath.opt.getOrElse( " " ) + request.getServletPath.opt.getOrElse( " " )
30
+ val pathPrefix = request.getContextPath.orEmpty + request.getServletPath.orEmpty
31
31
val path = PathValue .splitDecode(request.getRequestURI.stripPrefix(pathPrefix))
32
32
val query = request.getQueryString.opt.map(QueryValue .decode).getOrElse(Mapping .empty)
33
33
val headersBuilder = Mapping .newBuilder[HeaderValue ]
You can’t perform that action at this time.
0 commit comments