Skip to content

Commit 2c6252e

Browse files
committed
crates-io/cloudfront-functions: Add support for download URLs without placeholders
1 parent ba0cb0a commit 2c6252e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

terragrunt/modules/crates-io/cloudfront-functions/static-router.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,15 @@ function handler(event) {
77
request.uri = request.uri.replace("+", "%2B");
88
}
99

10+
// cargo versions before 1.24 don't support placeholders in the `dl` field
11+
// of the index, so we need to rewrite the download URL to point to the
12+
// crate file instead.
13+
var match = request.uri.match(/^\/crates\/([^\/]+)\/([^\/]+)\/download$/);
14+
if (match) {
15+
var crate = match[1];
16+
var version = match[2];
17+
request.uri = `/crates/${crate}/${crate}-${version}.crate`;
18+
}
19+
1020
return request;
1121
}

0 commit comments

Comments
 (0)