Skip to content

Commit

Permalink
chore: Adding extension to strip first prefix from string (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
wooj2 committed Jan 20, 2022
1 parent 567abc3 commit 0faded8
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,14 @@ extension String {
return ByteBuffer(data: self.data(using: .utf8) ?? Data())
}
}

public extension String {
func stripFirstMatching(prefixes: [String]) -> String {
for prefixToStrip in prefixes {
if self.hasPrefix(prefixToStrip) {
return self.removePrefix(prefixToStrip)
}
}
return self
}
}

0 comments on commit 0faded8

Please sign in to comment.