From 8db3333cddb589934408fcba1281753b05b8e6c0 Mon Sep 17 00:00:00 2001 From: DENG Qingfang Date: Sat, 2 Nov 2019 23:10:40 +0800 Subject: [PATCH] download.pl: add jsDelivr mirror for GitHub jsDelivr has CDN servers in Mainland China (as well as rest of the world) so it can be used to accelerate downloading. jsDelivr uses the following URL for GitHub files: https://cdn.jsdelivr.net/gh/{username}/{repo}@{revision}/path/to/file For compatibility, the script will replace the 2nd '/' with '@' when pushing the jsDelivr URL to mirrors. Signed-off-by: DENG Qingfang --- scripts/download.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/download.pl b/scripts/download.pl index c14ec07e44..2b1ffde51e 100755 --- a/scripts/download.pl +++ b/scripts/download.pl @@ -267,9 +267,13 @@ foreach my $mirror (@ARGV) { push @mirrors, "https://mirrors.tuna.tsinghua.edu.cn/apache/$1"; push @mirrors, "https://mirrors.ustc.edu.cn/apache/$1"; } elsif ($mirror =~ /^\@GITHUB\/(.+)$/) { + my $dir = $1; + my $i = 0; + # replace the 2nd '/' with '@' for jsDelivr mirror + push @mirrors, "https://cdn.jsdelivr.net/gh/". $dir =~ s{\/}{++$i == 2 ? '@' : $&}ger; # give github a few more tries (different mirrors) for (1 .. 5) { - push @mirrors, "https://raw.githubusercontent.com/$1"; + push @mirrors, "https://raw.githubusercontent.com/$dir"; } } elsif ($mirror =~ /^\@GNU\/(.+)$/) { push @mirrors, "https://mirror.csclub.uwaterloo.ca/gnu/$1"; -- 2.30.2