Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: simplify empty check #2329

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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