Skip to content

Commit

Permalink
Support valid URI chars in max_age glob
Browse files Browse the repository at this point in the history
  • Loading branch information
laurilehmijoki committed Jan 5, 2015
1 parent e3efbf1 commit 06ddfc4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/scala/s3/website/model/push.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ case class Upload(originalFile: File, uploadType: UploadType)(implicit site: Sit
val matchingMaxAge = (glob: String, maxAge: Int) =>
rubyRuntime.evalScriptlet(
s"""|# encoding: utf-8
|File.fnmatch('$glob', '$s3Key')""".stripMargin)
|File.fnmatch('$glob', "$s3Key")""".stripMargin)
.toJava(classOf[Boolean])
.asInstanceOf[Boolean]
val fileGlobMatch = globs find Function.tupled(matchingMaxAge)
Expand Down
11 changes: 11 additions & 0 deletions src/test/scala/s3/website/S3WebsiteSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,17 @@ class S3WebsiteSpec extends Specification {
sentPutObjectRequest.getMetadata.getCacheControl must equalTo("max-age=60")
}

"supports all valid URI characters in the glob setting" in new BasicSetup {
config = """
|max_age:
| "*.html": 90
""".stripMargin
val allValidUrlCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=" // See http://stackoverflow.com/a/1547940/990356 for discussion
setLocalFile(s"$allValidUrlCharacters.html")
push
sentPutObjectRequest.getMetadata.getCacheControl must equalTo("max-age=90")
}

"be applied to files that match the glob" in new BasicSetup {
config = """
|max_age:
Expand Down

0 comments on commit 06ddfc4

Please sign in to comment.