Skip to content

Accept node-set suffixes in ends-with - #175

Open
rudycelekli wants to merge 1 commit into
antchfx:masterfrom
rudycelekli:fix/ends-with-node-suffix-20261029
Open

rudycelekli wants to merge 1 commit into
antchfx:masterfrom
rudycelekli:fix/ends-with-node-suffix-20261029

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

ends-with("Everyday Italian", //book[1]/title) compiles but panics during evaluation because only the first argument accepts a node-set. The equivalent call with string(//book[1]/title) works. This prevents XML/HTML queries from comparing a string against a suffix stored in another node.

Apply the same existing string/node-set conversion to both arguments. A selected node contributes its string value and an empty node-set contributes the empty string. Numeric and boolean arguments retain their existing rejection behavior.

Validation on upstream base 6a83bdc6e20f75669fea1f29402e1f2ea8676111:

  • All six new regression cases panic on the unmodified base, covering matching/nonmatching suffixes, both arguments from nodes, and empty suffix selections.
  • go test ./... and go test -race ./... pass after the fix with Go 1.26.4 on macOS arm64, including the existing tests that reject numeric arguments.
  • git diff --check passes.

The expected suffix results follow the ends-with rules and the package's existing first-argument node-set conversion. This does not add collations or general XPath 2.0 support.

AI assistance: implementation and regression tests prepared with Codex.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 85.691% (-0.02%) from 85.71% — rudycelekli:fix/ends-with-node-suffix-20261029 into antchfx:master

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants