preactjs / preact-iso

Isomorphic utilities for Preact
MIT License
69 stars 9 forks source link

fix: Wildcard splat/rest param matches should return `undefined` instead of empty strings #45

Closed rschristian closed 1 week ago

rschristian commented 1 week ago

Whilst https://github.com/preactjs/wmr/commit/d503514743da838f086d5760fbc62144f93fc774 added a test entry for /:x* paths, unfortunately it copied the test block for optional params (/:x?) and only updated the test name -- the actual test cases were duplicates that didn't ensure what they were meant to.

This PR therefore corrects that and adds proper tests, but also ensures optional params become undefined, rather than empty strings, to match the behavior of /:x? in the case of the param not being set. I'd call this non-breaking as the previous behavior isn't correct or consistent and any falsy check will still fail all the same.