Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
targeturl = urlparse.urljoin(self.source_url, url)
if targeturl.startswith(to_replace):
url = "%s%s" % (sub, targeturl[len(to_replace):])
# Only apply the first match
break
else:
# External mode: use ExternalAssets objects
# to fetch replacements
if len(self.external):
# If path is an absolute one, keep it
if not self._is_abs_url(url):
replacement = None
file_path = urlpath.pathjoin(self.source_path, url)
asset_path = None
for external_assets in self.external:
# see if our file has a versioned version available
try:
asset_path = external_assets.versioned_folder(file_path)
break
except IOError:
pass
if asset_path is not None:
if self.env.url:
# see if it's a complete url (rather than a folder)
# otherwise we want a relative path in the CSS
if self.env.url.startswith('http://')\
or self.env.url.startswith('https://')\
or self.env.url.startswith('//'):