We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 66b3305 commit b0c0e1fCopy full SHA for b0c0e1f
1 file changed
src/routing/api.js
@@ -43,3 +43,24 @@ function makeMatcherWithoutParams(route) {
43
extractQuery,
44
}
45
46
+
47
+function extractQuery(path) {
48
+ const queryIndex = path.indexOf('?');
49
50
+ if (queryIndex === -1) {
51
+ return {};
52
+ }
53
54
+ const search = new URLSearchParams(path.slice(queryIndex + 1));
55
56
+ return Object.entries(search.entries());
57
+}
58
59
+// const route = { path: '/home' }
60
+// const matcher = makeMatcherWithoutParams(route)
61
62
+// matcher.checkMatch('/users') // false
63
+// matcher.checkMatch('/home') // true
64
65
+// matcher.extractQuery('/home') // {}
66
+// matcher.extractQuery('/home?tab=profile') // { tab: 'profile' }
0 commit comments