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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfec8ac2ce1c72f5738bfc30b25a351b2bb48f2a
4
- data.tar.gz: 4e0baba6c1728328f1433dc53c2e0c11c71c4933
3
+ metadata.gz: 07675e2836114a62d64ba9c4f3cb1d468979def7
4
+ data.tar.gz: 79ec43e71d28fa9eb6852883f3845a91c71adba5
5
5
  SHA512:
6
- metadata.gz: 26cb367f6797262c1e5b31a23fc85606321e9d9a98e368674bd2b3970042eb56f244e09201233402980112f97a16183db602edcef131b41ac20ed3a84cc569dd
7
- data.tar.gz: 555ba6e52cbdfb53ab70f385a59d6177b14b995ed76e2e09f3e44d38dc7e3ea82b684d9b0096edf2766ebe1b04a5bd9ddbaa6fd2f3610a9390308a3e6964e38d
6
+ metadata.gz: 5b8da0a144df3b8e6a9af48457927f54e9991afd9d81a7eb00ab215c754d72905727dc14298bbeade33190b2a88c14f27fca0e2b28cfbc11bdaaa13e8d60124c
7
+ data.tar.gz: 83b3cc06196da7997bcd5f0d051c70e08b7ccc0d224c04070adc14e675788fc15c5e90c2d503489d46f854057373c5757969a579315c37059380bff5d9d267f2
data/README.md CHANGED
@@ -279,7 +279,7 @@ as key-value pairs under the `redirects` configuration option:
279
279
  ```yaml
280
280
  redirects:
281
281
  index.php: /
282
- about.php: about.html
282
+ about.php: /about.html
283
283
  music-files/promo.mp4: http://www.youtube.com/watch?v=dQw4w9WgXcQ
284
284
  ```
285
285
 
data/changelog.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This project uses [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## 2.1.6
6
+
7
+ * Automatically add slash to redirects if needed
8
+
5
9
  ## 2.1.5
6
10
 
7
11
  * Target JVM 1.6 in build.sbt
@@ -1,3 +1,3 @@
1
1
  module S3Website
2
- VERSION = '2.1.5'
2
+ VERSION = '2.1.6'
3
3
  end
@@ -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:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_website
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lauri Lehmijoki