@@ -328,16 +328,32 @@ def analyze(self, fname, find_sources=False, check_remote=False):
328
328
os .path .join (os .path .dirname (filename ).encode ('utf-8' ), unquoted_target ))
329
329
330
330
elif url_type in ('full_path' , 'absolute' ):
331
+ relative = False
331
332
if url_type == 'absolute' :
332
333
# convert to 'full_path' case, ie url relative to root
333
- url_rel_path = parsed .path [len (url_netloc_to_root ):]
334
+ if parsed .path .startswith (url_netloc_to_root ):
335
+ url_rel_path = parsed .path [len (url_netloc_to_root ):]
336
+ else :
337
+ url_rel_path = parsed .path
338
+ if not url_rel_path .startswith ('/' ):
339
+ relative = True
334
340
else :
335
341
# convert to relative to base path
336
- url_rel_path = target [len (url_netloc_to_root ):]
342
+ if target .startswith (url_netloc_to_root ):
343
+ url_rel_path = target [len (url_netloc_to_root ):]
344
+ else :
345
+ url_rel_path = target
346
+ if not url_rel_path .startswith ('/' ):
347
+ relative = True
337
348
if url_rel_path == '' or url_rel_path .endswith ('/' ):
338
349
url_rel_path = urljoin (url_rel_path , self .site .config ['INDEX_FILE' ])
339
- fs_rel_path = fs_relpath_from_url_path (url_rel_path )
340
- target_filename = os .path .join (self .site .config ['OUTPUT_FOLDER' ], fs_rel_path )
350
+ if relative :
351
+ unquoted_target = unquote (target ).encode ('utf-8' )
352
+ target_filename = os .path .abspath (
353
+ os .path .join (os .path .dirname (filename ).encode ('utf-8' ), unquoted_target ))
354
+ else :
355
+ fs_rel_path = fs_relpath_from_url_path (url_rel_path )
356
+ target_filename = os .path .join (self .site .config ['OUTPUT_FOLDER' ], fs_rel_path )
341
357
342
358
if any (re .search (x , target_filename ) for x in self .whitelist ):
343
359
continue
0 commit comments