wovnrb 3.5.0 → 3.6.0
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/README.en.md +30 -13
- data/build.sh +7 -0
- data/docker/nginx/Dockerfile +18 -0
- data/docker/nginx/README.md +13 -0
- data/docker/nginx/build.sh +8 -0
- data/docker/nginx/scripts/configure_sshd.sh +25 -0
- data/docker/nginx/scripts/startup.sh +10 -0
- data/docker/nginx/wovnrb.conf +19 -0
- data/docker/rails/Dockerfile +9 -0
- data/docker/rails/Dockerfile.ECS +17 -0
- data/docker/rails/TestSite/Gemfile +0 -2
- data/docker/rails/TestSite/app/controllers/custom_response_controller.rb +1 -1
- data/docker/rails/TestSite/config/environments/development.rb +2 -0
- data/docker/rails/TestSite/config/environments/production.rb +2 -0
- data/docker/rails/TestSite/config/environments/test.rb +2 -0
- data/docker/rails/TestSite/public/index.html +1 -1
- data/docker/rails/TestSite/start.sh +2 -11
- data/docker/rails/TestSite/start_rails.sh +9 -0
- data/docker/rails/TestSite/yarn.lock +3 -3
- data/docker/scripts/jenkins/build.sh +45 -0
- data/docker/scripts/jenkins/tag_and_push_image.sh +30 -0
- data/docker/scripts/jenkins/taskdef.json +104 -0
- data/docker/scripts/jenkins/taskdef.json.bak +99 -0
- data/lib/wovnrb/api_translator.rb +6 -1
- data/lib/wovnrb/headers.rb +19 -2
- data/lib/wovnrb/services/html_converter.rb +17 -1
- data/lib/wovnrb/services/url.rb +136 -0
- data/lib/wovnrb/store.rb +8 -2
- data/lib/wovnrb/url_language_switcher.rb +124 -0
- data/lib/wovnrb/version.rb +1 -1
- data/lib/wovnrb.rb +3 -1
- data/test/lib/api_translator_test.rb +44 -0
- data/test/lib/services/html_converter_test.rb +210 -37
- data/test/lib/services/url_test.rb +308 -0
- data/test/lib/url_language_switcher_test.rb +798 -0
- data/test/lib/wovnrb_test.rb +2 -1
- data/test/test_helper.rb +4 -1
- metadata +22 -3
@@ -0,0 +1,308 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Wovnrb
|
4
|
+
class URLTest < WovnMiniTest
|
5
|
+
def test_normalize_url
|
6
|
+
assert_equal('http://domain.com', Wovnrb::URL.normalize_url('http://domain.com'))
|
7
|
+
assert_equal('http://domain.com', Wovnrb::URL.normalize_url('http://domain.com '))
|
8
|
+
assert_equal('http://domain.com', Wovnrb::URL.normalize_url(' http://domain.com'))
|
9
|
+
assert_equal('http://domain.com', Wovnrb::URL.normalize_url("\u200b http://domain.com"))
|
10
|
+
assert_equal('http://domain.com', Wovnrb::URL.normalize_url(" http:\u200b//domain.com\u200b"))
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_resolve_absolute_uri
|
14
|
+
assert_equal('http://domain.com', Wovnrb::URL.resolve_absolute_uri('http://domain.com', '').to_s)
|
15
|
+
assert_equal('http://domain.com/', Wovnrb::URL.resolve_absolute_uri('http://domain.com', '/').to_s)
|
16
|
+
assert_equal('http://domain.com/some/path', Wovnrb::URL.resolve_absolute_uri('http://domain.com', '/some/path').to_s)
|
17
|
+
assert_equal('http://domain.com/some/path', Wovnrb::URL.resolve_absolute_uri('http://domain.com/', '/some/path').to_s)
|
18
|
+
assert_equal('http://domain.com/some/path/', Wovnrb::URL.resolve_absolute_uri('http://domain.com/', '/some/path/').to_s)
|
19
|
+
assert_equal('http://domain.com/garbage_relative_path/', Wovnrb::URL.resolve_absolute_uri('http://domain.com/', '/../../garbage_relative_path/').to_s)
|
20
|
+
assert_equal('http://domain.com/root.html', Wovnrb::URL.resolve_absolute_uri('http://domain.com/dir1/dir2/page.html', '/.././../root.html').to_s)
|
21
|
+
assert_equal('http://domain.com/root.html?baz=123', Wovnrb::URL.resolve_absolute_uri('http://domain.com/dir1/dir2/page.html?foo=bar', '/.././../root.html?baz=123').to_s)
|
22
|
+
assert_equal('http://domain.com/some/path', Wovnrb::URL.resolve_absolute_uri('http://domain.com?foo=bar', '/some/path').to_s)
|
23
|
+
assert_equal('http://another_absolute_url.com/dir/', Wovnrb::URL.resolve_absolute_uri('http://domain.com?foo=bar', 'http://another_absolute_url.com/dir/').to_s)
|
24
|
+
assert_equal('http://another_absolute_url.com/dir/page', Wovnrb::URL.resolve_absolute_uri('http://domain.com?foo=bar', 'http://another_absolute_url.com/dir/../dir/page').to_s)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_resolve_absolute_path
|
28
|
+
assert_equal('', Wovnrb::URL.resolve_absolute_path('http://domain.com', ''))
|
29
|
+
assert_equal('/', Wovnrb::URL.resolve_absolute_path('http://domain.com/', ''))
|
30
|
+
assert_equal('/', Wovnrb::URL.resolve_absolute_path('http://domain.com', '/'))
|
31
|
+
assert_equal('/foo/bar', Wovnrb::URL.resolve_absolute_path('http://domain.com', '/foo/bar'))
|
32
|
+
assert_equal('/foo/bar', Wovnrb::URL.resolve_absolute_path('http://domain.com', 'foo/bar'))
|
33
|
+
assert_equal('/dir/foo/bar', Wovnrb::URL.resolve_absolute_path('http://domain.com/dir/', 'foo/bar'))
|
34
|
+
assert_equal('/dir/bar', Wovnrb::URL.resolve_absolute_path('http://domain.com/dir/', 'foo/../bar'))
|
35
|
+
assert_equal('/dir/bar?query=123#hash', Wovnrb::URL.resolve_absolute_path('http://domain.com/dir/', 'foo/../bar?query=123#hash'))
|
36
|
+
assert_equal('/fr/wovn_aaa/news/', Wovnrb::URL.resolve_absolute_path('https://pre.avex.jp/wovn_aaa/news/', '/fr/wovn_aaa/news/../news/'))
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_absolute_url
|
40
|
+
assert(Wovnrb::URL.absolute_url?('//foo.com'))
|
41
|
+
assert(Wovnrb::URL.absolute_url?('http://foo.com'))
|
42
|
+
assert(Wovnrb::URL.absolute_url?('https://foo.com'))
|
43
|
+
assert_not(Wovnrb::URL.absolute_url?('ftp://foo.com'))
|
44
|
+
assert_not(Wovnrb::URL.absolute_url?('foo'))
|
45
|
+
assert_not(Wovnrb::URL.absolute_url?('/foo'))
|
46
|
+
assert_not(Wovnrb::URL.absolute_url?('../foo'))
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_join_paths
|
50
|
+
assert_equal('', Wovnrb::URL.join_paths('', ''))
|
51
|
+
assert_equal('/', Wovnrb::URL.join_paths('', '/'))
|
52
|
+
assert_equal('/foo', Wovnrb::URL.join_paths('', '/foo'))
|
53
|
+
assert_equal('/foo/', Wovnrb::URL.join_paths('', '/foo/'))
|
54
|
+
|
55
|
+
assert_equal('/', Wovnrb::URL.join_paths('/', ''))
|
56
|
+
assert_equal('/foo', Wovnrb::URL.join_paths('/foo', ''))
|
57
|
+
assert_equal('/foo/', Wovnrb::URL.join_paths('/foo/', ''))
|
58
|
+
|
59
|
+
assert_equal('/foo/', Wovnrb::URL.join_paths('/foo/', ''))
|
60
|
+
assert_equal('/foo/bar', Wovnrb::URL.join_paths('/foo', 'bar'))
|
61
|
+
assert_equal('/foo/bar', Wovnrb::URL.join_paths('/foo/', 'bar'))
|
62
|
+
assert_equal('/foo/bar', Wovnrb::URL.join_paths('/foo/', '/bar'))
|
63
|
+
assert_equal('/foo/bar/', Wovnrb::URL.join_paths('/foo/', 'bar/'))
|
64
|
+
assert_equal('/foo/bar/', Wovnrb::URL.join_paths('/foo/', '/bar/'))
|
65
|
+
assert_equal('/foo/bar/', Wovnrb::URL.join_paths('/foo', 'bar/'))
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_absolute_path
|
69
|
+
assert_not(Wovnrb::URL.absolute_path?('http://foo.com'))
|
70
|
+
assert_not(Wovnrb::URL.absolute_path?('https://foo.com'))
|
71
|
+
assert_not(Wovnrb::URL.absolute_path?('foo'))
|
72
|
+
assert_not(Wovnrb::URL.absolute_path?('../foo'))
|
73
|
+
assert(Wovnrb::URL.absolute_path?('/foo'))
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_relative_path
|
77
|
+
assert_not(Wovnrb::URL.relative_path?('http://foo.com'))
|
78
|
+
assert_not(Wovnrb::URL.relative_path?('https://foo.com'))
|
79
|
+
assert(Wovnrb::URL.relative_path?('foo'))
|
80
|
+
assert(Wovnrb::URL.relative_path?('../foo'))
|
81
|
+
assert(Wovnrb::URL.relative_path?('./foo'))
|
82
|
+
assert_not(Wovnrb::URL.relative_path?('/foo'))
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_prepend_path
|
86
|
+
assert_equal('http://www.google.com/new_dir/test/', Wovnrb::URL.prepend_path('http://www.google.com/test/', 'new_dir'))
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_prepend_path_long_path
|
90
|
+
assert_equal('http://www.google.com/new_dir/test/try/again/', Wovnrb::URL.prepend_path('http://www.google.com/test/try/again/', 'new_dir'))
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_prepend_path_no_trailing_slash
|
94
|
+
assert_equal('http://www.google.com/new_dir/test', Wovnrb::URL.prepend_path('http://www.google.com/test', 'new_dir'))
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_prepend_path_long_path_no_trailing_slash
|
98
|
+
assert_equal('http://www.google.com/new_dir/test/try/again', Wovnrb::URL.prepend_path('http://www.google.com/test/try/again', 'new_dir'))
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_prepend_path_no_path
|
102
|
+
assert_equal('http://www.google.com/new_dir/', Wovnrb::URL.prepend_path('http://www.google.com/', 'new_dir'))
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_prepend_path_no_path_no_trailing_slash
|
106
|
+
assert_equal('http://www.google.com/new_dir', Wovnrb::URL.prepend_path('http://www.google.com', 'new_dir'))
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_prepend_path_no_host
|
110
|
+
assert_equal('http://google.com/new_dir/test/', Wovnrb::URL.prepend_path('http://google.com/test/', 'new_dir'))
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_prepend_path_no_host_long_path
|
114
|
+
assert_equal('http://google.com/new_dir/test/try/again/', Wovnrb::URL.prepend_path('http://google.com/test/try/again/', 'new_dir'))
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_prepend_path_no_host_no_trailing_slash
|
118
|
+
assert_equal('http://google.com/new_dir/test', Wovnrb::URL.prepend_path('http://google.com/test', 'new_dir'))
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_prepend_path_no_host_long_path_no_trailing_slash
|
122
|
+
assert_equal('http://google.com/new_dir/test/try/again', Wovnrb::URL.prepend_path('http://google.com/test/try/again', 'new_dir'))
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_prepend_path_no_host_no_path
|
126
|
+
assert_equal('http://google.com/new_dir/', Wovnrb::URL.prepend_path('http://google.com/', 'new_dir'))
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_prepend_path_no_host_no_path_no_trailing_slash
|
130
|
+
assert_equal('http://google.com/new_dir', Wovnrb::URL.prepend_path('http://google.com', 'new_dir'))
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_prepend_path_no_protocol
|
134
|
+
assert_equal('www.facebook.com/dir/test/', Wovnrb::URL.prepend_path('www.facebook.com/test/', 'dir'))
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_prepend_path_no_protocol_long_path
|
138
|
+
assert_equal('www.facebook.com/dir/test/try/again/', Wovnrb::URL.prepend_path('www.facebook.com/test/try/again/', 'dir'))
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_prepend_path_no_protocol_no_trailing_slash
|
142
|
+
assert_equal('www.facebook.com/dir/test', Wovnrb::URL.prepend_path('www.facebook.com/test', 'dir'))
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_prepend_path_no_protocol_long_path_no_trailing_slash
|
146
|
+
assert_equal('www.facebook.com/dir/test/try/again', Wovnrb::URL.prepend_path('www.facebook.com/test/try/again', 'dir'))
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_prepend_path_no_protocol_no_path
|
150
|
+
assert_equal('www.facebook.com/dir/', Wovnrb::URL.prepend_path('www.facebook.com/', 'dir'))
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_prepend_path_no_protocol_no_path_no_trailing_slash
|
154
|
+
assert_equal('www.facebook.com/dir', Wovnrb::URL.prepend_path('www.facebook.com', 'dir'))
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_prepend_path_no_protocoli_no_host
|
158
|
+
assert_equal('facebook.com/dir/test/', Wovnrb::URL.prepend_path('facebook.com/test/', 'dir'))
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_prepend_path_no_protocol_no_host_long_path
|
162
|
+
assert_equal('facebook.com/dir/test/try/again/', Wovnrb::URL.prepend_path('facebook.com/test/try/again/', 'dir'))
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_prepend_path_no_protocol_no_host_no_trailing_slash
|
166
|
+
assert_equal('facebook.com/dir/test', Wovnrb::URL.prepend_path('facebook.com/test', 'dir'))
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_prepend_path_no_protocol_no_host_long_path_no_trailing_slash
|
170
|
+
assert_equal('facebook.com/dir/test/try/again', Wovnrb::URL.prepend_path('facebook.com/test/try/again', 'dir'))
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_prepend_path_no_protocol_no_host_no_path
|
174
|
+
assert_equal('facebook.com/dir/', Wovnrb::URL.prepend_path('facebook.com/', 'dir'))
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_prepend_path_no_protocol_no_host_no_path_no_trailing_slash
|
178
|
+
assert_equal('facebook.com/dir', Wovnrb::URL.prepend_path('facebook.com', 'dir'))
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_prepend_path_no_protocol_with_double_slash
|
182
|
+
assert_equal('//www.yahoo.com/dir/test/', Wovnrb::URL.prepend_path('//www.yahoo.com/test/', 'dir'))
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_prepend_path_no_protocol_long_path_with_double_slash
|
186
|
+
assert_equal('//www.yahoo.com/dir/test/try/again/', Wovnrb::URL.prepend_path('//www.yahoo.com/test/try/again/', 'dir'))
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_prepend_path_no_protocol_no_trailing_slash_with_double_slash
|
190
|
+
assert_equal('//www.yahoo.com/dir/test', Wovnrb::URL.prepend_path('//www.yahoo.com/test', 'dir'))
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_prepend_path_no_protocol_long_path_no_trailing_slash_with_double_slash
|
194
|
+
assert_equal('//www.yahoo.com/dir/test/try/again', Wovnrb::URL.prepend_path('//www.yahoo.com/test/try/again', 'dir'))
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_prepend_path_no_protocol_no_path_with_double_slash
|
198
|
+
assert_equal('//www.yahoo.com/dir/', Wovnrb::URL.prepend_path('//www.yahoo.com/', 'dir'))
|
199
|
+
end
|
200
|
+
|
201
|
+
def test_prepend_path_no_protocol_no_path_no_trailing_slash_with_double_slash
|
202
|
+
assert_equal('//www.yahoo.com/dir', Wovnrb::URL.prepend_path('//www.yahoo.com', 'dir'))
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_prepend_path_no_protocol_no_host_with_double_slash
|
206
|
+
assert_equal('//yahoo.com/dir/test/', Wovnrb::URL.prepend_path('//yahoo.com/test/', 'dir'))
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_prepend_path_no_protocol_no_host_long_path_with_double_slash
|
210
|
+
assert_equal('//yahoo.com/dir/test/try/again/', Wovnrb::URL.prepend_path('//yahoo.com/test/try/again/', 'dir'))
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_prepend_path_no_protocol_no_host_no_trailing_slash_with_double_slash
|
214
|
+
assert_equal('//yahoo.com/dir/test', Wovnrb::URL.prepend_path('//yahoo.com/test', 'dir'))
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_prepend_path_no_protocol_no_host_long_path_no_trailing_slash_with_double_slash
|
218
|
+
assert_equal('//yahoo.com/dir/test/try/again', Wovnrb::URL.prepend_path('//yahoo.com/test/try/again', 'dir'))
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_prepend_path_no_protocol_no_host_no_path_with_double_slash
|
222
|
+
assert_equal('//yahoo.com/dir/', Wovnrb::URL.prepend_path('//yahoo.com/', 'dir'))
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_prepend_path_no_protocol_no_host_no_path_no_trailing_slash_with_double_slash
|
226
|
+
assert_equal('//yahoo.com/dir', Wovnrb::URL.prepend_path('//yahoo.com', 'dir'))
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_valid_protocol?
|
230
|
+
assert_equal(true, Wovnrb::URL.valid_protocol?('http://foo.com'))
|
231
|
+
assert_equal(true, Wovnrb::URL.valid_protocol?('https://foo.com/index.html'))
|
232
|
+
assert_equal(false, Wovnrb::URL.valid_protocol?('data:;base64,iVBORw0KGgo='))
|
233
|
+
assert_equal(false, Wovnrb::URL.valid_protocol?('tel:+817044446666'))
|
234
|
+
assert_equal(false, Wovnrb::URL.valid_protocol?('ftp://site.com:8000/cat.png'))
|
235
|
+
|
236
|
+
assert_equal(true, Wovnrb::URL.valid_protocol?('site.com:8000/index.html'))
|
237
|
+
assert_equal(true, Wovnrb::URL.valid_protocol?('/page/index.html?user=tom'))
|
238
|
+
assert_equal(true, Wovnrb::URL.valid_protocol?('../index.html'))
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_file?
|
242
|
+
assert_equal(false, Wovnrb::URL.file?(''))
|
243
|
+
assert_equal(false, Wovnrb::URL.file?('example.com'))
|
244
|
+
assert_equal(false, Wovnrb::URL.file?('Download rain.mp3 for background noise'))
|
245
|
+
assert_equal(false, Wovnrb::URL.file?('http://example.com?q=dog.png'))
|
246
|
+
assert_equal(false, Wovnrb::URL.file?('https://site.jp'))
|
247
|
+
assert_equal(false, Wovnrb::URL.file?('https://site.jp/'))
|
248
|
+
assert_equal(false, Wovnrb::URL.file?('https://site.jp?user=tom'))
|
249
|
+
assert_equal(false, Wovnrb::URL.file?('https://site.jp/?user=tom'))
|
250
|
+
assert_equal(false, Wovnrb::URL.file?('https://site.jp#top'))
|
251
|
+
assert_equal(false, Wovnrb::URL.file?('https://site.jp/#top'))
|
252
|
+
assert_equal(false, Wovnrb::URL.file?('https://site.jp/index.html'))
|
253
|
+
|
254
|
+
assert_equal(true, Wovnrb::URL.file?('https://example.com/images/baloon.png'))
|
255
|
+
assert_equal(true, Wovnrb::URL.file?('/new/stan.mp3'))
|
256
|
+
assert_equal(true, Wovnrb::URL.file?('https://box.com/user/chad/beef_stew.zip'))
|
257
|
+
assert_equal(true, Wovnrb::URL.file?('https://site.jp/beef_stew.zip'))
|
258
|
+
assert_equal(true, Wovnrb::URL.file?('/dir/some.pdf'))
|
259
|
+
assert_equal(true, Wovnrb::URL.file?('/dir/some.doc'))
|
260
|
+
assert_equal(true, Wovnrb::URL.file?('/dir/some.docx'))
|
261
|
+
assert_equal(true, Wovnrb::URL.file?('/dir/some.xls'))
|
262
|
+
assert_equal(true, Wovnrb::URL.file?('/dir/some.xlsx'))
|
263
|
+
assert_equal(true, Wovnrb::URL.file?('/dir/some.xlsm'))
|
264
|
+
end
|
265
|
+
|
266
|
+
def test_path_and_query
|
267
|
+
assert_equal('', Wovnrb::URL.path_and_query(Addressable::URI.parse('http://domain.com')))
|
268
|
+
assert_equal('?foo=bar', Wovnrb::URL.path_and_query(Addressable::URI.parse('http://domain.com?foo=bar')))
|
269
|
+
assert_equal('?', Wovnrb::URL.path_and_query(Addressable::URI.parse('http://domain.com?')))
|
270
|
+
|
271
|
+
assert_equal('/', Wovnrb::URL.path_and_query(Addressable::URI.parse('http://domain.com/')))
|
272
|
+
assert_equal('/?foo=bar', Wovnrb::URL.path_and_query(Addressable::URI.parse('http://domain.com/?foo=bar')))
|
273
|
+
|
274
|
+
assert_equal('/dir/path', Wovnrb::URL.path_and_query(Addressable::URI.parse('http://domain.com/dir/path')))
|
275
|
+
assert_equal('/dir/path?foo=bar', Wovnrb::URL.path_and_query(Addressable::URI.parse('http://domain.com/dir/path?foo=bar')))
|
276
|
+
end
|
277
|
+
|
278
|
+
def test_path_and_query_and_hash
|
279
|
+
assert_equal('', Wovnrb::URL.path_and_query_and_hash(Addressable::URI.parse('http://domain.com')))
|
280
|
+
assert_equal('?', Wovnrb::URL.path_and_query_and_hash(Addressable::URI.parse('http://domain.com?')))
|
281
|
+
assert_equal('?foo=bar', Wovnrb::URL.path_and_query_and_hash(Addressable::URI.parse('http://domain.com?foo=bar')))
|
282
|
+
assert_equal('#fragment', Wovnrb::URL.path_and_query_and_hash(Addressable::URI.parse('http://domain.com#fragment')))
|
283
|
+
assert_equal('/', Wovnrb::URL.path_and_query_and_hash(Addressable::URI.parse('http://domain.com/')))
|
284
|
+
assert_equal('/#fragment', Wovnrb::URL.path_and_query_and_hash(Addressable::URI.parse('http://domain.com/#fragment')))
|
285
|
+
assert_equal('/?foo=bar', Wovnrb::URL.path_and_query_and_hash(Addressable::URI.parse('http://domain.com/?foo=bar')))
|
286
|
+
assert_equal('/?foo=bar#fragment', Wovnrb::URL.path_and_query_and_hash(Addressable::URI.parse('http://domain.com/?foo=bar#fragment')))
|
287
|
+
assert_equal('/dir/path', Wovnrb::URL.path_and_query_and_hash(Addressable::URI.parse('http://domain.com/dir/path')))
|
288
|
+
assert_equal('/dir/path#fragment', Wovnrb::URL.path_and_query_and_hash(Addressable::URI.parse('http://domain.com/dir/path#fragment')))
|
289
|
+
assert_equal('/dir/path?foo=bar', Wovnrb::URL.path_and_query_and_hash(Addressable::URI.parse('http://domain.com/dir/path?foo=bar')))
|
290
|
+
assert_equal('/dir/path?foo=bar#fragment', Wovnrb::URL.path_and_query_and_hash(Addressable::URI.parse('http://domain.com/dir/path?foo=bar#fragment')))
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_change_protocol
|
294
|
+
assert_equal('https://domain.com', Wovnrb::URL.change_protocol(Addressable::URI.parse('http://domain.com'), 'https').to_s)
|
295
|
+
assert_equal('http://domain.com', Wovnrb::URL.change_protocol(Addressable::URI.parse('https://domain.com'), 'http').to_s)
|
296
|
+
assert_equal('//domain.com', Wovnrb::URL.change_protocol(Addressable::URI.parse('https://domain.com'), nil).to_s)
|
297
|
+
assert_equal('http://domain.com', Wovnrb::URL.change_protocol(Addressable::URI.parse('//domain.com'), 'http').to_s)
|
298
|
+
end
|
299
|
+
|
300
|
+
def test_normalize_path_slash
|
301
|
+
assert_equal('/en/dir1/dir2/', Wovnrb::URL.normalize_path_slash('/dir1/dir2/', '/en/dir1/dir2/'))
|
302
|
+
assert_equal('/en/dir1/dir2', Wovnrb::URL.normalize_path_slash('/dir1/dir2', '/en/dir1/dir2/'))
|
303
|
+
assert_equal('/en/dir1/dir2/', Wovnrb::URL.normalize_path_slash('/dir1/dir2/', '/en/dir1/dir2'))
|
304
|
+
assert_equal('/', Wovnrb::URL.normalize_path_slash('/', '/'))
|
305
|
+
assert_equal('', Wovnrb::URL.normalize_path_slash('', '/'))
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|