urlpattern 0.1.5__tar.gz → 0.1.6__tar.gz

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.
@@ -182,9 +182,9 @@ jobs:
182
182
  strategy:
183
183
  matrix:
184
184
  platform:
185
- - runner: macos-13
185
+ - runner: macos-15-intel
186
186
  target: x86_64
187
- - runner: macos-14
187
+ - runner: macos-latest
188
188
  target: aarch64
189
189
  steps:
190
190
  - uses: actions/checkout@v4
@@ -91,9 +91,9 @@ checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a"
91
91
 
92
92
  [[package]]
93
93
  name = "icu_properties"
94
- version = "2.1.1"
94
+ version = "2.1.2"
95
95
  source = "registry+https://github.com/rust-lang/crates.io-index"
96
- checksum = "e93fcd3157766c0c8da2f8cff6ce651a31f0810eaa1c51ec363ef790bbb5fb99"
96
+ checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec"
97
97
  dependencies = [
98
98
  "icu_collections",
99
99
  "icu_locale_core",
@@ -105,9 +105,9 @@ dependencies = [
105
105
 
106
106
  [[package]]
107
107
  name = "icu_properties_data"
108
- version = "2.1.1"
108
+ version = "2.1.2"
109
109
  source = "registry+https://github.com/rust-lang/crates.io-index"
110
- checksum = "02845b3647bb045f1100ecd6480ff52f34c35f82d9880e029d329c21d1054899"
110
+ checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af"
111
111
 
112
112
  [[package]]
113
113
  name = "icu_provider"
@@ -195,9 +195,9 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
195
195
 
196
196
  [[package]]
197
197
  name = "portable-atomic"
198
- version = "1.11.1"
198
+ version = "1.13.0"
199
199
  source = "registry+https://github.com/rust-lang/crates.io-index"
200
- checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
200
+ checksum = "f89776e4d69bb58bc6993e99ffa1d11f228b839984854c7daeb5d37f87cbe950"
201
201
 
202
202
  [[package]]
203
203
  name = "potential_utf"
@@ -210,9 +210,9 @@ dependencies = [
210
210
 
211
211
  [[package]]
212
212
  name = "proc-macro2"
213
- version = "1.0.103"
213
+ version = "1.0.104"
214
214
  source = "registry+https://github.com/rust-lang/crates.io-index"
215
- checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
215
+ checksum = "9695f8df41bb4f3d222c95a67532365f569318332d03d5f3f67f37b20e6ebdf0"
216
216
  dependencies = [
217
217
  "unicode-ident",
218
218
  ]
@@ -280,7 +280,7 @@ dependencies = [
280
280
 
281
281
  [[package]]
282
282
  name = "python-urlpattern"
283
- version = "0.1.5"
283
+ version = "0.1.6"
284
284
  dependencies = [
285
285
  "pyo3",
286
286
  "urlpattern",
@@ -396,9 +396,9 @@ dependencies = [
396
396
 
397
397
  [[package]]
398
398
  name = "target-lexicon"
399
- version = "0.13.3"
399
+ version = "0.13.4"
400
400
  source = "registry+https://github.com/rust-lang/crates.io-index"
401
- checksum = "df7f62577c25e07834649fc3b39fafdc597c0a3527dc1c60129201ccfcbaa50c"
401
+ checksum = "b1dd07eb858a2067e2f3c7155d54e929265c264e6f37efe3ee7a8d1b5a1dd0ba"
402
402
 
403
403
  [[package]]
404
404
  name = "tinystr"
@@ -436,9 +436,9 @@ dependencies = [
436
436
 
437
437
  [[package]]
438
438
  name = "urlpattern"
439
- version = "0.4.1"
439
+ version = "0.4.2"
440
440
  source = "registry+https://github.com/rust-lang/crates.io-index"
441
- checksum = "957a88ad1abd5d13336275adb17d4f9b6a2404f3baed2e075e0b026dc0b2b58d"
441
+ checksum = "0f805818f843b548bacc19609eb3619dd2850e54746f5cada37927393c2ef4ec"
442
442
  dependencies = [
443
443
  "icu_properties",
444
444
  "regex",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "python-urlpattern"
3
- version = "0.1.5"
3
+ version = "0.1.6"
4
4
  authors = ["방성범 (Bang Seongbeom) <bangseongbeom@gmail.com>"]
5
5
  edition = "2024"
6
6
  description = "An implementation of the URL Pattern Standard for Python written in Rust."
@@ -16,4 +16,4 @@ crate-type = ["cdylib"]
16
16
 
17
17
  [dependencies]
18
18
  pyo3 = "0.27.2"
19
- deno_urlpattern = { package = "urlpattern", version = "0.4.1" }
19
+ deno_urlpattern = { package = "urlpattern", version = "0.4.2" }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: urlpattern
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -40,7 +40,7 @@ An implementation of [the URL Pattern Standard](https://urlpattern.spec.whatwg.o
40
40
 
41
41
  ## Introduction
42
42
 
43
- The URL Pattern Standard is a web standard for URL pattern matching. It is useful on the server side when serving different pages based on the URL. It provides pattern matching syntax like `/users/:id`, similar to [route parameters in Express](https://expressjs.com/en/guide/routing.html#route-parameters) or [Path-to-RegExp](https://github.com/pillarjs/path-to-regexp). You can use it as a foundation to build your own web server or framework.
43
+ The URL Pattern Standard is a web standard for URL pattern matching. It is useful on the server side when serving different pages based on the URL (a.k.a. routing). It provides pattern matching syntax like `/users/:id`, similar to [route parameters in Express](https://expressjs.com/en/guide/routing.html#route-parameters) or [Path-to-RegExp](https://github.com/pillarjs/path-to-regexp). You can use it as a foundation to build your own web server or framework.
44
44
 
45
45
  It's a thin wrapper of [denoland/rust-urlpattern](https://github.com/denoland/rust-urlpattern) with [PyO3](https://github.com/PyO3/pyo3) + [Maturin](https://github.com/PyO3/maturin).
46
46
 
@@ -60,11 +60,11 @@ py -m pip install urlpattern
60
60
 
61
61
  ## Usage
62
62
 
63
- Check [urlpattern.pyi](urlpattern.pyi).
63
+ Check [urlpattern.pyi](https://github.com/urlpattern/python-urlpattern/blob/main/urlpattern.pyi) or the examples below.
64
64
 
65
- ## Examples
65
+ For various usage examples, you can also check [Chrome for Developers](https://developer.chrome.com/docs/web-platform/urlpattern) or [MDN](https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API) (you need to convert JavaScript into Python).
66
66
 
67
- For various usage examples, refer to [Chrome for Developers](https://developer.chrome.com/docs/web-platform/urlpattern) or [MDN](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) (you may need to convert JavaScript into Python).
67
+ ## Examples
68
68
 
69
69
  ### `test`
70
70
 
@@ -103,20 +103,33 @@ print(pattern.test("https://example.com/TeST")) # output: True
103
103
  ### Simple WSGI app
104
104
 
105
105
  ```py
106
- from urlpattern import URLPattern
107
106
  from wsgiref.simple_server import make_server
108
107
 
108
+ from urlpattern import URLPattern
109
109
 
110
110
  user_id_pattern = URLPattern({"pathname": "/users/:id"})
111
111
 
112
112
 
113
+ def get_user_id(environ, start_response):
114
+ user_id = environ["result"]["pathname"]["groups"]["id"]
115
+ status = "200 OK"
116
+ response_headers = [("Content-type", "text/plain; charset=utf-8")]
117
+ start_response(status, response_headers)
118
+ return [f"{user_id=}".encode()]
119
+
120
+
113
121
  def app(environ, start_response):
114
122
  path = environ["PATH_INFO"]
123
+ method = environ["REQUEST_METHOD"]
115
124
 
116
125
  if result := user_id_pattern.exec({"pathname": path}):
117
- user_id = result["pathname"]["groups"]["id"]
118
- start_response("200 OK", [("Content-Type", "text/plain; charset=utf-8")])
119
- return [f"{user_id=}".encode()]
126
+ if method == "GET":
127
+ return get_user_id(environ | {"result": result}, start_response)
128
+
129
+ status = "404 Not Found"
130
+ response_headers = [("Content-type", "text/plain; charset=utf-8")]
131
+ start_response(status, response_headers)
132
+ return [b"Not Found"]
120
133
 
121
134
 
122
135
  with make_server("", 8000, app) as httpd:
@@ -127,5 +140,5 @@ with make_server("", 8000, app) as httpd:
127
140
 
128
141
  Due to limitations in the dependency [denoland/rust-urlpattern](https://github.com/denoland/rust-urlpattern), it may not support all features specified in [the standard](https://urlpattern.spec.whatwg.org/).
129
142
 
130
- Check the `pytest.skip` in [`tests/test_lib.py`](tests/test_lib.py).
143
+ Check `pytest.skip` in [`tests/test_lib.py`](https://github.com/urlpattern/python-urlpattern/blob/main/tests/test_lib.py).
131
144
 
@@ -9,7 +9,7 @@ An implementation of [the URL Pattern Standard](https://urlpattern.spec.whatwg.o
9
9
 
10
10
  ## Introduction
11
11
 
12
- The URL Pattern Standard is a web standard for URL pattern matching. It is useful on the server side when serving different pages based on the URL. It provides pattern matching syntax like `/users/:id`, similar to [route parameters in Express](https://expressjs.com/en/guide/routing.html#route-parameters) or [Path-to-RegExp](https://github.com/pillarjs/path-to-regexp). You can use it as a foundation to build your own web server or framework.
12
+ The URL Pattern Standard is a web standard for URL pattern matching. It is useful on the server side when serving different pages based on the URL (a.k.a. routing). It provides pattern matching syntax like `/users/:id`, similar to [route parameters in Express](https://expressjs.com/en/guide/routing.html#route-parameters) or [Path-to-RegExp](https://github.com/pillarjs/path-to-regexp). You can use it as a foundation to build your own web server or framework.
13
13
 
14
14
  It's a thin wrapper of [denoland/rust-urlpattern](https://github.com/denoland/rust-urlpattern) with [PyO3](https://github.com/PyO3/pyo3) + [Maturin](https://github.com/PyO3/maturin).
15
15
 
@@ -29,11 +29,11 @@ py -m pip install urlpattern
29
29
 
30
30
  ## Usage
31
31
 
32
- Check [urlpattern.pyi](urlpattern.pyi).
32
+ Check [urlpattern.pyi](https://github.com/urlpattern/python-urlpattern/blob/main/urlpattern.pyi) or the examples below.
33
33
 
34
- ## Examples
34
+ For various usage examples, you can also check [Chrome for Developers](https://developer.chrome.com/docs/web-platform/urlpattern) or [MDN](https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API) (you need to convert JavaScript into Python).
35
35
 
36
- For various usage examples, refer to [Chrome for Developers](https://developer.chrome.com/docs/web-platform/urlpattern) or [MDN](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern) (you may need to convert JavaScript into Python).
36
+ ## Examples
37
37
 
38
38
  ### `test`
39
39
 
@@ -72,20 +72,33 @@ print(pattern.test("https://example.com/TeST")) # output: True
72
72
  ### Simple WSGI app
73
73
 
74
74
  ```py
75
- from urlpattern import URLPattern
76
75
  from wsgiref.simple_server import make_server
77
76
 
77
+ from urlpattern import URLPattern
78
78
 
79
79
  user_id_pattern = URLPattern({"pathname": "/users/:id"})
80
80
 
81
81
 
82
+ def get_user_id(environ, start_response):
83
+ user_id = environ["result"]["pathname"]["groups"]["id"]
84
+ status = "200 OK"
85
+ response_headers = [("Content-type", "text/plain; charset=utf-8")]
86
+ start_response(status, response_headers)
87
+ return [f"{user_id=}".encode()]
88
+
89
+
82
90
  def app(environ, start_response):
83
91
  path = environ["PATH_INFO"]
92
+ method = environ["REQUEST_METHOD"]
84
93
 
85
94
  if result := user_id_pattern.exec({"pathname": path}):
86
- user_id = result["pathname"]["groups"]["id"]
87
- start_response("200 OK", [("Content-Type", "text/plain; charset=utf-8")])
88
- return [f"{user_id=}".encode()]
95
+ if method == "GET":
96
+ return get_user_id(environ | {"result": result}, start_response)
97
+
98
+ status = "404 Not Found"
99
+ response_headers = [("Content-type", "text/plain; charset=utf-8")]
100
+ start_response(status, response_headers)
101
+ return [b"Not Found"]
89
102
 
90
103
 
91
104
  with make_server("", 8000, app) as httpd:
@@ -96,4 +109,4 @@ with make_server("", 8000, app) as httpd:
96
109
 
97
110
  Due to limitations in the dependency [denoland/rust-urlpattern](https://github.com/denoland/rust-urlpattern), it may not support all features specified in [the standard](https://urlpattern.spec.whatwg.org/).
98
111
 
99
- Check the `pytest.skip` in [`tests/test_lib.py`](tests/test_lib.py).
112
+ Check `pytest.skip` in [`tests/test_lib.py`](https://github.com/urlpattern/python-urlpattern/blob/main/tests/test_lib.py).
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes