File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -372,6 +372,30 @@ def test_get_base_url(self):
372
372
get_base_url (text , baseurl .encode ("ascii" )), "http://example.org/something"
373
373
)
374
374
375
+ def test_base_url_in_comment (self ):
376
+ self .assertEqual (
377
+ get_base_url ("""<!-- <base href="http://example.com/"/> -->""" ), ""
378
+ )
379
+ self .assertEqual (
380
+ get_base_url ("""<!-- <base href="http://example.com/"/>""" ), ""
381
+ )
382
+ self .assertEqual (
383
+ get_base_url ("""<!-- <base href="http://example.com/"/> --""" ), ""
384
+ )
385
+ self .assertEqual (
386
+ get_base_url (
387
+ """<!-- <!-- <base href="http://example.com/"/> -- --> <base href="http://example_2.com/"/> """
388
+ ),
389
+ "http://example_2.com/" ,
390
+ )
391
+
392
+ self .assertEqual (
393
+ get_base_url (
394
+ """<!-- <base href="http://example.com/"/> --> <!-- <base href="http://example_2.com/"/> --> <base href="http://example_3.com/"/>"""
395
+ ),
396
+ "http://example_3.com/" ,
397
+ )
398
+
375
399
def test_relative_url_with_absolute_path (self ):
376
400
baseurl = "https://example.org"
377
401
text = """\
Original file line number Diff line number Diff line change @@ -311,7 +311,7 @@ def get_base_url(
311
311
312
312
"""
313
313
314
- utext = to_unicode (text , encoding )
314
+ utext : str = remove_comments (text , encoding = encoding )
315
315
m = _baseurl_re .search (utext )
316
316
if m :
317
317
return urljoin (
You can’t perform that action at this time.
0 commit comments