File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change
1
+ # How to use the URLPattern API
2
+
3
+ The URLPattern API is currently available in Chrome 93 and later behind a flag.
4
+
5
+ 1 . Download Chrome ([ Android] ( https://play.google.com/store/apps/details?id=com.android.chrome ) , [ Desktop] ( https://www.google.com/chrome/ ) ).
6
+ 2 . Navigate to ` chrome://flags ` and enable ` Experimental Web Platform features ` .
7
+ 3 . Visit a page that uses ` URLPattern ` , such as the [ demo on glitch] ( https://urlpattern-sw-routing.glitch.me/ ) .
8
+
9
+ Here is an example of how to use the API:
10
+
11
+ ``` javascript
12
+ const pattern = new URLPattern ({ pathname: ' /:product/index.html' });
13
+ const result = pattern .exec (someURL);
14
+ if (result) {
15
+ handleProduct (result .pathname .groups .product );
16
+ }
17
+ ```
18
+
19
+ More code examples can be found in the [ URLPattern documentation] ( docs/urlpattern.md ) .
You can’t perform that action at this time.
0 commit comments