ensure_ends_with
If the string doesn’t end with the substring specified as the 1st parameter, it adds it after the string, otherwise it returns the original string.
Example:
"foo"?ensure_ends_with("/")
It returns foo/
"foo/"?ensure_ends_with("/")
It also returns foo/
ensure_starts_with
If the string doesn’t start with the substring specified as the 1st parameter, it adds it before the string, otherwise it returns the original string.
Example:
“foo”?ensure_starts_with(“/”)
It returns /foo
“/foo”?ensure_starts_with(“/”)
It also returns /foo