Skip to content

An implementation of the URL Pattern Standard for Python written in Rust.

License

Notifications You must be signed in to change notification settings

urlpattern/python-urlpattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Pattern

PyPI - Version PyPI - Python Version Ruff CI

An implementation of the URL Pattern Standard for Python written in Rust

This is a thin wrapper of denoland/rust-urlpattern with PyO3 + Maturin.

Installation

On Linux/UNIX or macOS:

pip install urlpattern

On Windows:

py -m pip install urlpattern

Example

from urlpattern import URLPattern

pattern = URLPattern("https://example.com/*")
print(pattern.test("https://example.com/foo/bar"))  # output: True

pattern = URLPattern({"pathname": "/:foo/:bar"})
result = pattern.exec("/abc/def", "https://test.example")
print(result["pathname"]["groups"]["foo"])  # output: abc
print(result["pathname"]["groups"]["bar"])  # output: def

About

An implementation of the URL Pattern Standard for Python written in Rust.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •