Skip to content

Commit 79ba428

Browse files
committed
Fixed privacy plugin not picking up protocol-relative URLs
1 parent 61cad24 commit 79ba428

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

material/plugins/privacy/plugin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,13 @@ def _fetch(self, file: File, config: MkDocsConfig):
479479
if not os.path.isfile(file.abs_src_path) or not self.config.cache:
480480
path = file.abs_src_path
481481

482+
# In case the URL is a protocol-relative URL that starts with `//`,
483+
# we prepend `http:` as a scheme, assuming that all external assets
484+
# are available via HTTP. If we'd require `https:`, some external
485+
# assets might not be fetchable.
486+
if file.url.startswith("//"):
487+
file.url = f"http:{file.url}"
488+
482489
# Download external asset
483490
log.info(f"Downloading external file: {file.url}")
484491
try:

src/plugins/privacy/plugin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,13 @@ def _fetch(self, file: File, config: MkDocsConfig):
479479
if not os.path.isfile(file.abs_src_path) or not self.config.cache:
480480
path = file.abs_src_path
481481

482+
# In case the URL is a protocol-relative URL that starts with `//`,
483+
# we prepend `http:` as a scheme, assuming that all external assets
484+
# are available via HTTP. If we'd require `https:`, some external
485+
# assets might not be fetchable.
486+
if file.url.startswith("//"):
487+
file.url = f"http:{file.url}"
488+
482489
# Download external asset
483490
log.info(f"Downloading external file: {file.url}")
484491
try:

0 commit comments

Comments
 (0)