Skip to content

Commit

Permalink
Update starts_with and ends_with
Browse files Browse the repository at this point in the history
Support empty prefix and postfix
  • Loading branch information
atuonufure committed Dec 4, 2023
1 parent f05c649 commit f34f07c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fhirpathpy/engine/invocations/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ def substring(ctx, coll, start, length=None):


def starts_with(ctx, coll, prefix):
if util.is_empty(prefix):
return []
string = ensure_string_singleton(coll)
if not string or not isinstance(prefix, str):
return False
return string.startswith(prefix)


def ends_with(ctx, coll, postfix):
if util.is_empty(postfix):
return []
string = ensure_string_singleton(coll)
if not string or not isinstance(postfix, str):
return False
Expand Down

0 comments on commit f34f07c

Please sign in to comment.