File tree 2 files changed +8
-6
lines changed
2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -64,8 +64,8 @@ def on_config(self, config):
64
64
# Initialize collections of external assets
65
65
self .assets = Files ([])
66
66
self .assets_expr_map = {
67
- ".css" : r"url\(( \s*http?[^)]+)\)" ,
68
- ".js" : r"[\"'](http[^\"']+\.(?:css|js(?:on)?))[\"']" ,
67
+ ".css" : r"url\(\s*([\"']?)(?P<url> http?[^)'\" ]+)\1\s* \)" ,
68
+ ".js" : r"[\"'](?P<url> http[^\"']+\.(?:css|js(?:on)?))[\"']" ,
69
69
** self .config .assets_expr_map
70
70
}
71
71
@@ -271,7 +271,8 @@ def _parse_media(self, initiator: File) -> list[URL]:
271
271
# Find and extract all external asset URLs
272
272
expr = re .compile (self .assets_expr_map [extension ], flags = re .I | re .M )
273
273
with open (initiator .abs_src_path , encoding = "utf-8-sig" ) as f :
274
- return [urlparse (url ) for url in re .findall (expr , f .read ())]
274
+ results = re .finditer (expr , f .read ())
275
+ return [urlparse (result .group ("url" )) for result in results ]
275
276
276
277
# Parse template or page HTML and find all external links that need to be
277
278
# replaced. Many of the assets should already be downloaded earlier, i.e.,
Original file line number Diff line number Diff line change @@ -64,8 +64,8 @@ def on_config(self, config):
64
64
# Initialize collections of external assets
65
65
self .assets = Files ([])
66
66
self .assets_expr_map = {
67
- ".css" : r"url\(( \s*http?[^)]+)\)" ,
68
- ".js" : r"[\"'](http[^\"']+\.(?:css|js(?:on)?))[\"']" ,
67
+ ".css" : r"url\(\s*([\"']?)(?P<url> http?[^)'\" ]+)\1\s* \)" ,
68
+ ".js" : r"[\"'](?P<url> http[^\"']+\.(?:css|js(?:on)?))[\"']" ,
69
69
** self .config .assets_expr_map
70
70
}
71
71
@@ -271,7 +271,8 @@ def _parse_media(self, initiator: File) -> list[URL]:
271
271
# Find and extract all external asset URLs
272
272
expr = re .compile (self .assets_expr_map [extension ], flags = re .I | re .M )
273
273
with open (initiator .abs_src_path , encoding = "utf-8-sig" ) as f :
274
- return [urlparse (url ) for url in re .findall (expr , f .read ())]
274
+ results = re .finditer (expr , f .read ())
275
+ return [urlparse (result .group ("url" )) for result in results ]
275
276
276
277
# Parse template or page HTML and find all external links that need to be
277
278
# replaced. Many of the assets should already be downloaded earlier, i.e.,
You can’t perform that action at this time.
0 commit comments