trenni 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trenni/uri.rb +2 -2
- data/lib/trenni/version.rb +1 -1
- data/spec/trenni/uri_spec.rb +7 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f537bf7c125e2f4e23c5e6ab5126d15370ee4e9a
|
4
|
+
data.tar.gz: c73fe7e8da34eaab7ab8be0ceec116181d06e462
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6355020eedd0017f3c8f5c578df1eb38ae59503e054556f6799a34f4ad51b794b531e552b123cf9a03e6e244db7d13dea52028ce4d3bad1d950cfe92678effb
|
7
|
+
data.tar.gz: f51f05a10d786b7250939e372efc31c878b6e18f507b707f92b2b11d42da5913ec62adae781a847650083f7c37da5493a8bbc3bce18da3f6879e2c74bc382447
|
data/lib/trenni/uri.rb
CHANGED
@@ -64,13 +64,13 @@ module Trenni
|
|
64
64
|
private
|
65
65
|
|
66
66
|
# According to https://tools.ietf.org/html/rfc3986#section-3.3, we escape non-pchar.
|
67
|
-
NON_PCHAR = /([^
|
67
|
+
NON_PCHAR = /([^a-zA-Z0-9_\-\.~!$&'()*+,;=:@\/]+)/.freeze
|
68
68
|
|
69
69
|
def escape_path(path)
|
70
70
|
encoding = path.encoding
|
71
71
|
path.b.gsub(NON_PCHAR) do |m|
|
72
72
|
'%' + m.unpack('H2' * m.bytesize).join('%').upcase
|
73
|
-
end.
|
73
|
+
end.force_encoding(encoding)
|
74
74
|
end
|
75
75
|
|
76
76
|
# Escapes a generic string, using percent encoding.
|
data/lib/trenni/version.rb
CHANGED
data/spec/trenni/uri_spec.rb
CHANGED
@@ -25,7 +25,13 @@ require 'trenni/uri'
|
|
25
25
|
RSpec.describe Trenni::URI do
|
26
26
|
describe Trenni::URI('path with spaces/image.jpg') do
|
27
27
|
it "encodes whitespace" do
|
28
|
-
expect(subject.to_s).to be == "path
|
28
|
+
expect(subject.to_s).to be == "path%20with%20spaces/image.jpg"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe Trenni::URI('path_with_underscores/image.jpg') do
|
33
|
+
it "doesn't touch underscores" do
|
34
|
+
expect(subject.to_s).to be == "path_with_underscores/image.jpg"
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|