summaryrefslogtreecommitdiff
path: root/cloudinit/distros/__init__.py
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2020-03-31 17:04:17 -0400
committerGitHub <noreply@github.com>2020-03-31 17:04:17 -0400
commit1bbc4908ff7a2be19483811b3b6fee6ebc916235 (patch)
treeb357588131b799793c53a61ce8381acd2737ee56 /cloudinit/distros/__init__.py
parentf51e3d0e23b2873f077d1b7b3ac6874b94b1a374 (diff)
downloadvyos-cloud-init-1bbc4908ff7a2be19483811b3b6fee6ebc916235.tar.gz
vyos-cloud-init-1bbc4908ff7a2be19483811b3b6fee6ebc916235.zip
distros: drop leading/trailing hyphens from mirror URL labels (#296)
* distros/tests/test_init: drop needless brackets/indentation * distros: drop leading/trailing hyphens from mirror URL labels
Diffstat (limited to 'cloudinit/distros/__init__.py')
-rwxr-xr-xcloudinit/distros/__init__.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index 86a22c3e..e63b8c7a 100755
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -816,6 +816,11 @@ def _sanitize_mirror_url(url: str):
lambda hostname: ''.join(
c if c in acceptable_chars else "-" for c in hostname
),
+
+ # Drop leading/trailing hyphens from each part of the hostname
+ lambda hostname: '.'.join(
+ part.strip('-') for part in hostname.split('.')
+ ),
]
return _apply_hostname_transformations_to_url(url, transformations)