s3_website_monadic 0.0.4 → 0.0.5

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: 001860d8f4b29eae3c6d2f4e71d4e815a09bd068
4
- data.tar.gz: 2c39928790f622d404855dc548858bd06960c46a
3
+ metadata.gz: 64e9b6093bd40e0e6728a66dcfcf5134e5b72d52
4
+ data.tar.gz: 6aa1819b0581575150f767fc253f63a635c53a43
5
5
  SHA512:
6
- metadata.gz: 1c33fa0f3299e3852a67bc2267f9afc8b6895833f9ce5007f5615aca50080f443fbe4f1ef84b92a36d062790179e3819686f1e797b4c8851b9e8340f5dd6d0d1
7
- data.tar.gz: 620e2e04c5d145b2e86be58662c5669223f446ab480d8dd5259209c8b6ed2c0ea476d058160a0c545bee0677c766b608dfe5f997033c06e85446af2c0a99de0a
6
+ metadata.gz: 7dcb71a7dd601dca1d6d85f387f97170f7c09eb9e185db2755334af4137f99e42877fffca2ec46ca8995efbaa17ab78fd32dbae866cb91dfbf7b8122263f2f68
7
+ data.tar.gz: 3fc944d61d92e04cf7d20532a091a3492c9d22e237c41a659087cb3c8175ff2c023ca8d4fbf59fcf92636007c93fa2b08241f68f21589ab670d7669204004dca
data/s3_website.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "s3_website_monadic"
6
- s.version = "0.0.4"
6
+ s.version = "0.0.5"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Lauri Lehmijoki"]
9
9
  s.email = ["lauri.lehmijoki@iki.fi"]
@@ -15,6 +15,8 @@ import scala.util.Failure
15
15
  import s3.website.CloudFront.SuccessfulInvalidation
16
16
  import scala.util.Success
17
17
  import s3.website.CloudFront.FailedInvalidation
18
+ import java.net.{URI, URLEncoder}
19
+ import java.net.URLEncoder.encode
18
20
 
19
21
  class CloudFront(implicit cfClient: CloudFrontClientProvider, sleepUnit: TimeUnit) {
20
22
 
@@ -82,7 +84,14 @@ object CloudFront {
82
84
  def toInvalidationBatches(pushSuccessReports: Seq[PushSuccessReport])(implicit config: Config): Seq[InvalidationBatch] =
83
85
  pushSuccessReports
84
86
  .filterNot(isRedirect) // Assume that redirect objects are never cached.
85
- .map("/" + _.s3Key) // CloudFront keys always have the slash in front
87
+ .map(report =>
88
+ new URI(
89
+ "http",
90
+ "cloudfront", // We want to use the encoder in the URI class. These must be passed in.
91
+ "/" + report.s3Key, // CloudFront keys have the slash in front
92
+ null
93
+ ).toURL.getPath // The URL class encodes the unsafe characters
94
+ )
86
95
  .map { path =>
87
96
  if (config.cloudfront_invalidate_root.exists(_ == true))
88
97
  path.replaceFirst("/index.html$", "/")
@@ -93,7 +93,9 @@ class S3WebsiteSpec extends Specification {
93
93
  Push.pushSite
94
94
  sentDelete must equalTo("old.html")
95
95
  }
96
-
96
+ }
97
+
98
+ "push with CloudFront" should {
97
99
  "invalidate the CloudFront items" in new SiteDirectory with MockAWS {
98
100
  implicit val site = siteWithFiles(
99
101
  config = defaultConfig.copy(cloudfront_distribution_id = Some("EGM1J2JJX9Z")),
@@ -120,6 +122,15 @@ class S3WebsiteSpec extends Specification {
120
122
  Push.pushSite must equalTo(0) // The retries should finally result in a success
121
123
  sentInvalidationRequests.length must equalTo(4)
122
124
  }
125
+
126
+ "encode unsafe characters in the keys" in new SiteDirectory with MockAWS {
127
+ implicit val site = siteWithFiles(
128
+ config = defaultConfig.copy(cloudfront_distribution_id = Some("EGM1J2JJX9Z")),
129
+ localFiles = "articles/arnold's file.html" :: Nil
130
+ )
131
+ Push.pushSite
132
+ sentInvalidationRequest.getInvalidationBatch.getPaths.getItems.toSeq.sorted must equalTo(("/articles/arnold's%20file.html" :: Nil).sorted)
133
+ }
123
134
  }
124
135
 
125
136
  "cloudfront_invalidate_root: true" should {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_website_monadic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lauri Lehmijoki