@b9g/match-pattern 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -93,20 +93,20 @@ new MatchPattern({
|
|
|
93
93
|
})
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
## Trailing Slash
|
|
96
|
+
## Trailing Slash Handling
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
**Issue:** [kenchris/urlpattern-polyfill#131](https://github.com/kenchris/urlpattern-polyfill/issues/131)
|
|
101
|
-
|
|
102
|
-
**Solution:** ✅ Automatic trailing slash normalization implemented
|
|
98
|
+
MatchPattern does not automatically normalize trailing slashes. Use explicit patterns:
|
|
103
99
|
|
|
104
100
|
```javascript
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
101
|
+
// Exact matching
|
|
102
|
+
const exactPattern = new MatchPattern('/api/posts/:id');
|
|
103
|
+
exactPattern.test('/api/posts/123'); // ✅ true
|
|
104
|
+
exactPattern.test('/api/posts/123/'); // ❌ false
|
|
105
|
+
|
|
106
|
+
// Optional trailing slash
|
|
107
|
+
const flexiblePattern = new MatchPattern('/api/posts/:id{/}?');
|
|
108
|
+
flexiblePattern.test('/api/posts/123'); // ✅ true
|
|
109
|
+
flexiblePattern.test('/api/posts/123/'); // ✅ true
|
|
110
110
|
```
|
|
111
111
|
|
|
112
112
|
## Known Limitations
|
package/package.json
CHANGED