download.pl: add jsDelivr mirror for GitHub
[openwrt/staging/jow.git] / scripts / download.pl
index c14ec07e448d6799e16a78b8f772f998a8206e81..2b1ffde51e3df9e89d23cca9af32f71e644ff3af 100755 (executable)
@@ -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";