15 lines
311 B
Python
15 lines
311 B
Python
import urllib.parse
|
|
|
|
|
|
class UnicodeSlugConverter:
|
|
"""
|
|
支持中文 slug 的路径转换器
|
|
匹配除 / 之外的任意字符
|
|
"""
|
|
regex = '[^/]+'
|
|
|
|
def to_python(self, value):
|
|
return urllib.parse.unquote(value)
|
|
|
|
def to_url(self, value):
|
|
return urllib.parse.quote(value) |