s3_website 2.1.5 → 2.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/changelog.md +4 -0
- data/lib/s3_website/version.rb +1 -1
- data/src/main/scala/s3/website/model/push.scala +10 -1
- data/src/test/scala/s3/website/S3WebsiteSpec.scala +27 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07675e2836114a62d64ba9c4f3cb1d468979def7
|
4
|
+
data.tar.gz: 79ec43e71d28fa9eb6852883f3845a91c71adba5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b8da0a144df3b8e6a9af48457927f54e9991afd9d81a7eb00ab215c754d72905727dc14298bbeade33190b2a88c14f27fca0e2b28cfbc11bdaaa13e8d60124c
|
7
|
+
data.tar.gz: 83b3cc06196da7997bcd5f0d051c70e08b7ccc0d224c04070adc14e675788fc15c5e90c2d503489d46f854057373c5757969a579315c37059380bff5d9d267f2
|
data/README.md
CHANGED
data/changelog.md
CHANGED
data/lib/s3_website/version.rb
CHANGED
@@ -155,9 +155,18 @@ object Redirect {
|
|
155
155
|
config.redirects.fold(Nil: Seq[Redirect]) { sourcesToTargets =>
|
156
156
|
sourcesToTargets.foldLeft(Seq(): Seq[Redirect]) {
|
157
157
|
(redirects, sourceToTarget) =>
|
158
|
-
redirects :+ Redirect(sourceToTarget._1, sourceToTarget._2)
|
158
|
+
redirects :+ Redirect(sourceToTarget._1, applySlashIfNeeded(sourceToTarget._2))
|
159
159
|
}
|
160
160
|
}
|
161
|
+
|
162
|
+
private def applySlashIfNeeded(redirectTarget: String) = {
|
163
|
+
val isExternalRedirect = redirectTarget.matches("https?:\\/\\/.*")
|
164
|
+
val isInSiteRedirect = redirectTarget.startsWith("/")
|
165
|
+
if (isInSiteRedirect || isExternalRedirect)
|
166
|
+
redirectTarget
|
167
|
+
else
|
168
|
+
"/" + redirectTarget // let the user have redirect settings like "index.php: index.html" in s3_website.ml
|
169
|
+
}
|
161
170
|
}
|
162
171
|
|
163
172
|
case class S3File(s3Key: String, md5: MD5)
|
@@ -444,6 +444,33 @@ class S3WebsiteSpec extends Specification {
|
|
444
444
|
sentPutObjectRequest.getRedirectLocation must equalTo("/index.html")
|
445
445
|
}
|
446
446
|
|
447
|
+
"add slash to the redirect target" in new AllInSameDirectory with EmptySite with MockAWS with DefaultRunMode {
|
448
|
+
config = """
|
449
|
+
|redirects:
|
450
|
+
| index.php: index.html
|
451
|
+
""".stripMargin
|
452
|
+
push
|
453
|
+
sentPutObjectRequest.getRedirectLocation must equalTo("/index.html")
|
454
|
+
}
|
455
|
+
|
456
|
+
"support external redirects" in new AllInSameDirectory with EmptySite with MockAWS with DefaultRunMode {
|
457
|
+
config = """
|
458
|
+
|redirects:
|
459
|
+
| index.php: http://www.youtube.com/watch?v=dQw4w9WgXcQ
|
460
|
+
""".stripMargin
|
461
|
+
push
|
462
|
+
sentPutObjectRequest.getRedirectLocation must equalTo("http://www.youtube.com/watch?v=dQw4w9WgXcQ")
|
463
|
+
}
|
464
|
+
|
465
|
+
"support external redirects that point to an HTTPS target" in new AllInSameDirectory with EmptySite with MockAWS with DefaultRunMode {
|
466
|
+
config = """
|
467
|
+
|redirects:
|
468
|
+
| index.php: https://www.youtube.com/watch?v=dQw4w9WgXcQ
|
469
|
+
""".stripMargin
|
470
|
+
push
|
471
|
+
sentPutObjectRequest.getRedirectLocation must equalTo("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
|
472
|
+
}
|
473
|
+
|
447
474
|
"result in max-age=0 Cache-Control header on the object" in new AllInSameDirectory with EmptySite with MockAWS with DefaultRunMode {
|
448
475
|
config = """
|
449
476
|
|redirects:
|