File tree Expand file tree Collapse file tree 4 files changed +4
-21
lines changed Expand file tree Collapse file tree 4 files changed +4
-21
lines changed Original file line number Diff line number Diff line change @@ -639,7 +639,7 @@ def test_safe_url_performance(url):
639
639
# presummably due to caching by urllib.
640
640
number = 1 # TODO: Increase? How much?
641
641
# Make sure the new implementation is at most this number of times as slow.
642
- multiplier = 45 # TODO: Lower as close to 1 as possible.
642
+ multiplier = 40 # TODO: Lower as close to 1 as possible.
643
643
644
644
time1 = timeit (
645
645
f"safe_url({ url !r} )" , "from w3lib.url import safe_url" , number = number
Original file line number Diff line number Diff line change 10
10
11
11
12
12
def _check_contextj_rules (label : str ) -> None :
13
+ if label .isascii ():
14
+ return
13
15
for i , code_point in enumerate (label ):
14
16
value = ord (code_point )
15
17
if not intranges_contain (value , codepoint_classes ["CONTEXTJ" ]):
Original file line number Diff line number Diff line change @@ -432,25 +432,6 @@ def _starts_with_windows_drive_letter(input: str) -> bool:
432
432
)
433
433
434
434
435
- _ASCII_URL_CODE_POINTS = _ASCII_ALPHANUMERIC + "!$&'()*+,-./:;=?@_~"
436
-
437
-
438
- # https://url.spec.whatwg.org/commit-snapshots/a46cb9188a48c2c9d80ba32a9b1891652d6b4900/#url-code-points
439
- def _is_url_code_point (code_point : str ) -> bool :
440
- if code_point in _ASCII_URL_CODE_POINTS :
441
- return True
442
- code_point_id = ord (code_point )
443
- if code_point_id < 0xA0 :
444
- return False
445
- if code_point_id > 0x10FFFD :
446
- return False
447
- if _is_surrogate_code_point_id (code_point_id ):
448
- return False
449
- if _is_noncharacter_code_point_id (code_point_id ):
450
- return False
451
- return True
452
-
453
-
454
435
# https://url.spec.whatwg.org/commit-snapshots/a46cb9188a48c2c9d80ba32a9b1891652d6b4900/#double-dot-path-segment
455
436
def _is_double_dot_path_segment (input : str ) -> bool :
456
437
return input in (
Original file line number Diff line number Diff line change @@ -256,7 +256,7 @@ def _process(
256
256
257
257
258
258
def _convert_label (label : str ) -> str :
259
- if not any ( ord ( code_point ) >= 0x80 for code_point in label ):
259
+ if label . isascii ( ):
260
260
return label
261
261
return f"xn--{ label .encode ('punycode' ).decode ()} "
262
262
You can’t perform that action at this time.
0 commit comments