Skip to content

match: consider guarding against empty text input #1

Description

@mycargus

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:

  1. Add a guard: raise ArgumentError, "text must not be empty" in match(text)
  2. Document the asymmetry explicitly and leave it as-is (consistent with JS)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions