HomeSoftware Heritage

Allow start/end checks on empty strings

Description

Allow start/end checks on empty strings

When using this library function on strings that come from a parameter,
they might be empty sometimes, rendering it difficult to use, having to
force hacks like.

"_${source}".stdlib::start_with('_puppet:///modules/')

Where _ is added to make sure that the string is never empty.

In Ruby the start_with? function allows being used on empty strings,
and it returns false for any assertion to be done:

p ''.start_with?('test')
false

Also in Python the startswith() method returns false for empty
strings:

In [1]: print(''.startswith('test'))
False

As this logic seems the most extended and allows for a wider use of the
library, removing corner cases when the string comes empty.

Details

Provenance
Javier Santacruz <javier.santacruz@avature.net>Authored on Oct 22 2020, 1:55 PM
olasdPushed on Dec 28 2021, 10:47 AM
Parents
rSPSTD4b6cc319f11b: Merge pull request #1132 from b4ldr/type_httpstatus
Branches
Unknown
Tags
Unknown

Event Timeline

Javier Santacruz <javier.santacruz@avature.net> committed rSPSTD3dcdb96c876c: Allow start/end checks on empty strings (authored by Javier Santacruz <javier.santacruz@avature.net>).Oct 22 2020, 1:55 PM