Skip to content

Commit 208497b

Browse files
Support non-US-ASCII files when using ignore_on_server
1 parent deda470 commit 208497b

File tree

5 files changed

+33
-8
lines changed

5 files changed

+33
-8
lines changed

changelog.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
This project uses [Semantic Versioning](http://semver.org).
44

5+
## 2.1.16
6+
7+
* Support non-US-ASCII files when using `ignore_on_server`
8+
9+
Fixes https://github.com/laurilehmijoki/s3_website/issues/102
10+
511
## 2.1.15
612

713
* Support non-US-ASCII files when using `max_age`

lib/s3_website/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module S3Website
2-
VERSION = '2.1.15'
2+
VERSION = '2.1.16'
33
end

src/main/scala/s3/website/Ruby.scala

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ package s3.website
33
object Ruby {
44
lazy val rubyRuntime = org.jruby.Ruby.newInstance() // Instantiate heavy object
55

6-
def rubyRegexMatches(text: String, regex: String) =
7-
rubyRuntime.evalScriptlet(
8-
s"""
9-
!!Regexp.new('$regex').match('$text') # Use !! to force a boolean conversion
10-
"""
11-
).toJava(classOf[Boolean]).asInstanceOf[Boolean]
6+
def rubyRegexMatches(text: String, regex: String) = {
7+
val z = rubyRuntime.evalScriptlet(
8+
s"""# encoding: utf-8
9+
!!Regexp.new('$regex').match('$text')"""
10+
)
11+
z.toJava(classOf[Boolean]).asInstanceOf[Boolean]
12+
}
13+
1214
}

src/main/scala/s3/website/model/Config.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ object Config {
157157
def erbEval(erbString: String, yamlConfigPath: String): Try[String] = Try {
158158
val erbStringWithoutComments = erbString.replaceAll("^\\s*#.*", "")
159159
rubyRuntime.evalScriptlet(
160-
s"""
160+
s"""|# encoding: utf-8
161161
|require 'erb'
162162
|
163163
|str = <<-ERBSTR

src/test/scala/s3/website/S3WebsiteSpec.scala

+17
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,13 @@ class S3WebsiteSpec extends Specification {
338338
push
339339
noDeletesOccurred must beTrue
340340
}
341+
342+
"support non-US-ASCII files" in new AllInSameDirectory with EmptySite with MockAWS with DefaultRunMode {
343+
setS3Files(S3File("tags/笔记/test.html", ""))
344+
config = "ignore_on_server: tags/笔记/test.html"
345+
push
346+
noDeletesOccurred must beTrue
347+
}
341348
}
342349

343350
"""
@@ -354,6 +361,16 @@ class S3WebsiteSpec extends Specification {
354361
push
355362
noDeletesOccurred must beTrue
356363
}
364+
365+
"support non-US-ASCII files" in new AllInSameDirectory with EmptySite with MockAWS with DefaultRunMode {
366+
setS3Files(S3File("tags/笔记/test.html", ""))
367+
config = """
368+
|ignore_on_server:
369+
| - tags/笔记/test.html
370+
""".stripMargin
371+
push
372+
noDeletesOccurred must beTrue
373+
}
357374
}
358375

359376
"max-age in config" can {

0 commit comments

Comments
 (0)