match(text) currently accepts an empty string without raising, which is asymmetric with the empty-pattern guard.
Riteway.match("").call("hello") # => nil (no error)
Riteway.match("hello").call("") # => ArgumentError: pattern must not be empty
Passing empty text to match is likely a user bug. The JS riteway does not guard this either, so keeping it unguarded is a defensible choice — but worth a conscious decision.
Options:
- Add a guard:
raise ArgumentError, "text must not be empty" in match(text)
- Document the asymmetry explicitly and leave it as-is (consistent with JS)
match(text)currently accepts an empty string without raising, which is asymmetric with the empty-pattern guard.Passing empty text to
matchis likely a user bug. The JS riteway does not guard this either, so keeping it unguarded is a defensible choice — but worth a conscious decision.Options:
raise ArgumentError, "text must not be empty"inmatch(text)