Skip to content

Commit

Permalink
refactor: simplify empty check (#2329)
Browse files Browse the repository at this point in the history
  • Loading branch information
junghoon-vans authored Aug 31, 2023
1 parent a31493e commit 7d990ee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions zio-http/src/main/scala/zio/http/Path.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ final case class Path private (flags: Path.Flags, segments: Chunk[String]) { sel
*/
def addLeadingSlash: Path =
if (hasLeadingSlash) self
else if (segments.length == 0) Path(Flags(Flag.LeadingSlash), Chunk.empty)
else if (segments.isEmpty) Path(Flags(Flag.LeadingSlash), Chunk.empty)
else Path(Flag.LeadingSlash.add(flags), segments)

/**
* Appends a trailing slash to the path.
*/
def addTrailingSlash: Path =
if (hasTrailingSlash) self
else if (segments.length == 0) Path(Flags(Flag.TrailingSlash), Chunk.empty)
else if (segments.isEmpty) Path(Flags(Flag.TrailingSlash), Chunk.empty)
else Path(Flag.TrailingSlash.add(flags), segments)

/**
Expand Down Expand Up @@ -244,7 +244,7 @@ object Path {
* Decodes a path string into a Path.
*/
def decode(path: String): Path =
if (path.length == 0) Path.empty
if (path.isEmpty) Path.empty
else {
val chunkBuilder = ChunkBuilder.make[String]()

Expand Down

0 comments on commit 7d990ee

Please sign in to comment.