Strip quotes in detect-charset #618
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does
RFC 7231 Section 3.1.1.1 allows the charset specified in the
Content-Typeheader to be a quoted string. We wantdetect-charsetto return unquoted charset names, so that they can be passed to, say,java.nio.charset.Charset/forNamewithout postprocessing.This PR fixes that, adds a test for a quoted charset, and rewrites
t-detect-charset-by-content-typeto useclojure.test/areto reduce repetition and read more nicely.Implementation notes
are, as I find it to boost readability. Some people disagree, however, and findarea bit too magical. I'm not sure what position of this project is (I haven't seenareanywhere else), but I can rewrite it if needed. Let me know!{starts,ends}-with?fromclojure.string, but it would have broken compatibility with Clojure pre 1.8.0. So I resorted to Java interop.Tests
I get one failure when running
lein all test :all(stacktrace elided):Doesn't look like related to my changes. I think it's because I'm on OpenJDK 11 and the tests presuppose JDK 8. Plain
lein testcomes out all green.