addressable 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +9 -0
- data/coverage/index.html +5 -5
- data/coverage/lib-addressable-uri_rb.html +1116 -1103
- data/coverage/lib-addressable-version_rb.html +33 -33
- data/doc/classes/Addressable/URI.html +1237 -1202
- data/doc/classes/Addressable/URI/IDNA.html +34 -34
- data/doc/created.rid +1 -1
- data/doc/files/CHANGELOG.html +12 -2
- data/doc/files/lib/addressable/uri_rb.html +1 -1
- data/doc/files/lib/addressable/version_rb.html +1 -1
- data/doc/fr_method_index.html +58 -57
- data/lib/addressable/uri.rb +90 -77
- data/lib/addressable/version.rb +3 -3
- data/rakefile +6 -15
- data/spec/addressable/uri_spec.rb +503 -23
- metadata +2 -2
@@ -556,7 +556,7 @@ span.run100 {
|
|
556
556
|
</head>
|
557
557
|
<body>
|
558
558
|
<h3>C0 code coverage information</h3>
|
559
|
-
<p>Generated on
|
559
|
+
<p>Generated on Sat Nov 03 20:49:05 -0400 2007 with <a href='http://eigenclass.org/hiki.rb?rcov'>rcov 0.8.0</a>
|
560
560
|
</p>
|
561
561
|
<hr /><pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
562
562
|
</span><span class='marked1'>and this: this line is also marked as covered.
|
@@ -619,38 +619,38 @@ span.run100 {
|
|
619
619
|
</td>
|
620
620
|
</tr>
|
621
621
|
</tbody>
|
622
|
-
</table><pre><span class="
|
623
|
-
</span><span class="
|
624
|
-
</span><span class="
|
625
|
-
</span><span class="
|
626
|
-
</span><span class="
|
627
|
-
</span><span class="
|
628
|
-
</span><span class="
|
629
|
-
</span><span class="
|
630
|
-
</span><span class="
|
631
|
-
</span><span class="
|
632
|
-
</span><span class="
|
633
|
-
</span><span class="
|
634
|
-
</span><span class="
|
635
|
-
</span><span class="
|
636
|
-
</span><span class="
|
637
|
-
</span><span class="
|
638
|
-
</span><span class="
|
639
|
-
</span><span class="
|
640
|
-
</span><span class="
|
641
|
-
</span><span class="
|
642
|
-
</span><span class="
|
643
|
-
</span><span class="
|
644
|
-
</span><span class="
|
645
|
-
</span><span class="
|
646
|
-
</span><span class="
|
647
|
-
</span><span class="
|
648
|
-
</span><span class="
|
649
|
-
</span><span class="
|
650
|
-
</span><span class="
|
651
|
-
</span><span class="
|
652
|
-
</span><span class="
|
653
|
-
</span><span class="
|
622
|
+
</table><pre><span class="inferred0"><a name="line1" /> 1 #--
|
623
|
+
</span><span class="inferred1"><a name="line2" /> 2 # Addressable, Copyright (c) 2006-2007 Bob Aman
|
624
|
+
</span><span class="inferred0"><a name="line3" /> 3 #
|
625
|
+
</span><span class="inferred1"><a name="line4" /> 4 # Permission is hereby granted, free of charge, to any person obtaining
|
626
|
+
</span><span class="inferred0"><a name="line5" /> 5 # a copy of this software and associated documentation files (the
|
627
|
+
</span><span class="inferred1"><a name="line6" /> 6 # "Software"), to deal in the Software without restriction, including
|
628
|
+
</span><span class="inferred0"><a name="line7" /> 7 # without limitation the rights to use, copy, modify, merge, publish,
|
629
|
+
</span><span class="inferred1"><a name="line8" /> 8 # distribute, sublicense, and/or sell copies of the Software, and to
|
630
|
+
</span><span class="inferred0"><a name="line9" /> 9 # permit persons to whom the Software is furnished to do so, subject to
|
631
|
+
</span><span class="inferred1"><a name="line10" />10 # the following conditions:
|
632
|
+
</span><span class="inferred0"><a name="line11" />11 #
|
633
|
+
</span><span class="inferred1"><a name="line12" />12 # The above copyright notice and this permission notice shall be
|
634
|
+
</span><span class="inferred0"><a name="line13" />13 # included in all copies or substantial portions of the Software.
|
635
|
+
</span><span class="inferred1"><a name="line14" />14 #
|
636
|
+
</span><span class="inferred0"><a name="line15" />15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
637
|
+
</span><span class="inferred1"><a name="line16" />16 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
638
|
+
</span><span class="inferred0"><a name="line17" />17 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
639
|
+
</span><span class="inferred1"><a name="line18" />18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
640
|
+
</span><span class="inferred0"><a name="line19" />19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
641
|
+
</span><span class="inferred1"><a name="line20" />20 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
642
|
+
</span><span class="inferred0"><a name="line21" />21 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
643
|
+
</span><span class="inferred1"><a name="line22" />22 #++
|
644
|
+
</span><span class="inferred0"><a name="line23" />23
|
645
|
+
</span><span class="marked1"><a name="line24" />24 module Addressable
|
646
|
+
</span><span class="marked0"><a name="line25" />25 module ADDRESSABLE_VERSION #:nodoc:
|
647
|
+
</span><span class="marked1"><a name="line26" />26 MAJOR = 1
|
648
|
+
</span><span class="marked0"><a name="line27" />27 MINOR = 0
|
649
|
+
</span><span class="marked1"><a name="line28" />28 TINY = 0
|
650
|
+
</span><span class="inferred0"><a name="line29" />29
|
651
|
+
</span><span class="marked1"><a name="line30" />30 STRING = [MAJOR, MINOR, TINY].join('.')
|
652
|
+
</span><span class="inferred0"><a name="line31" />31 end
|
653
|
+
</span><span class="inferred1"><a name="line32" />32 end
|
654
654
|
</span></pre><hr /> <p>Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'>rcov code coverage analysis tool for Ruby</a> version 0.8.0.</p><p>
|
655
655
|
<a href='http://validator.w3.org/check/referer'>
|
656
656
|
<img src='http://www.w3.org/Icons/valid-xhtml10' height='31' alt='Valid XHTML 1.0!' width='88' />
|
@@ -93,62 +93,63 @@ RFC 3986, 3987.
|
|
93
93
|
<h3 class="section-bar">Methods</h3>
|
94
94
|
|
95
95
|
<div class="name-list">
|
96
|
-
<a href="#
|
97
|
-
<a href="#
|
98
|
-
<a href="#
|
99
|
-
<a href="#
|
100
|
-
<a href="#
|
101
|
-
<a href="#
|
102
|
-
<a href="#
|
103
|
-
<a href="#
|
104
|
-
<a href="#
|
105
|
-
<a href="#
|
106
|
-
<a href="#
|
107
|
-
<a href="#
|
108
|
-
<a href="#
|
109
|
-
<a href="#
|
110
|
-
<a href="#
|
111
|
-
<a href="#
|
112
|
-
<a href="#
|
113
|
-
<a href="#
|
114
|
-
<a href="#
|
115
|
-
<a href="#
|
116
|
-
<a href="#M000021">host
|
117
|
-
<a href="#
|
118
|
-
<a href="#
|
119
|
-
<a href="#
|
120
|
-
<a href="#
|
121
|
-
<a href="#
|
122
|
-
<a href="#
|
123
|
-
<a href="#
|
124
|
-
<a href="#
|
125
|
-
<a href="#
|
126
|
-
<a href="#
|
127
|
-
<a href="#M000048">normalize
|
128
|
-
<a href="#
|
96
|
+
<a href="#M000041">+</a>
|
97
|
+
<a href="#M000052">==</a>
|
98
|
+
<a href="#M000051">===</a>
|
99
|
+
<a href="#M000040">absolute?</a>
|
100
|
+
<a href="#M000023">authority</a>
|
101
|
+
<a href="#M000024">authority=</a>
|
102
|
+
<a href="#M000032">basename</a>
|
103
|
+
<a href="#M000003">convert_path</a>
|
104
|
+
<a href="#M000050">display_uri</a>
|
105
|
+
<a href="#M000054">dup</a>
|
106
|
+
<a href="#M000009">encode</a>
|
107
|
+
<a href="#M000007">encode_segment</a>
|
108
|
+
<a href="#M000053">eql?</a>
|
109
|
+
<a href="#M000004">expand_template</a>
|
110
|
+
<a href="#M000033">extname</a>
|
111
|
+
<a href="#M000011">extract</a>
|
112
|
+
<a href="#M000005">extract_mapping</a>
|
113
|
+
<a href="#M000036">fragment</a>
|
114
|
+
<a href="#M000037">fragment=</a>
|
115
|
+
<a href="#M000002">heuristic_parse</a>
|
116
|
+
<a href="#M000021">host</a>
|
117
|
+
<a href="#M000022">host=</a>
|
118
|
+
<a href="#M000057">inspect</a>
|
119
|
+
<a href="#M000038">ip_based?</a>
|
120
|
+
<a href="#M000025">ip_based_schemes</a>
|
121
|
+
<a href="#M000043">join</a>
|
122
|
+
<a href="#M000006">join</a>
|
123
|
+
<a href="#M000045">join!</a>
|
124
|
+
<a href="#M000042">merge</a>
|
125
|
+
<a href="#M000044">merge!</a>
|
126
|
+
<a href="#M000012">new</a>
|
127
|
+
<a href="#M000048">normalize</a>
|
128
|
+
<a href="#M000049">normalize!</a>
|
129
|
+
<a href="#M000010">normalized_encode</a>
|
129
130
|
<a href="#M000001">parse</a>
|
130
|
-
<a href="#
|
131
|
-
<a href="#
|
132
|
-
<a href="#
|
133
|
-
<a href="#
|
134
|
-
<a href="#
|
135
|
-
<a href="#
|
136
|
-
<a href="#
|
137
|
-
<a href="#
|
138
|
-
<a href="#
|
139
|
-
<a href="#
|
140
|
-
<a href="#
|
141
|
-
<a href="#
|
142
|
-
<a href="#
|
143
|
-
<a href="#
|
144
|
-
<a href="#
|
145
|
-
<a href="#
|
146
|
-
<a href="#
|
147
|
-
<a href="#
|
148
|
-
<a href="#
|
149
|
-
<a href="#
|
150
|
-
<a href="#
|
151
|
-
<a href="#
|
131
|
+
<a href="#M000017">password</a>
|
132
|
+
<a href="#M000018">password=</a>
|
133
|
+
<a href="#M000030">path</a>
|
134
|
+
<a href="#M000031">path=</a>
|
135
|
+
<a href="#M000027">port</a>
|
136
|
+
<a href="#M000028">port=</a>
|
137
|
+
<a href="#M000034">query</a>
|
138
|
+
<a href="#M000035">query=</a>
|
139
|
+
<a href="#M000039">relative?</a>
|
140
|
+
<a href="#M000046">route_from</a>
|
141
|
+
<a href="#M000047">route_to</a>
|
142
|
+
<a href="#M000013">scheme</a>
|
143
|
+
<a href="#M000014">scheme=</a>
|
144
|
+
<a href="#M000026">scheme_mapping</a>
|
145
|
+
<a href="#M000029">specified_port</a>
|
146
|
+
<a href="#M000056">to_hash</a>
|
147
|
+
<a href="#M000055">to_s</a>
|
148
|
+
<a href="#M000008">unencode_segment</a>
|
149
|
+
<a href="#M000015">user</a>
|
150
|
+
<a href="#M000016">user=</a>
|
151
|
+
<a href="#M000019">userinfo</a>
|
152
|
+
<a href="#M000020">userinfo=</a>
|
152
153
|
</div>
|
153
154
|
</div>
|
154
155
|
|
@@ -193,67 +194,67 @@ Class <a href="URI/InvalidURIError.html" class="link">Addressable::URI::InvalidU
|
|
193
194
|
<div id="methods">
|
194
195
|
<h3 class="section-bar">Public Class methods</h3>
|
195
196
|
|
196
|
-
<div id="method-
|
197
|
-
<a name="
|
197
|
+
<div id="method-M000003" class="method-detail">
|
198
|
+
<a name="M000003"></a>
|
198
199
|
|
199
200
|
<div class="method-heading">
|
200
|
-
<a href="#
|
201
|
+
<a href="#M000003" class="method-signature">
|
201
202
|
<span class="method-name">convert_path</span><span class="method-args">(path)</span>
|
202
203
|
</a>
|
203
204
|
</div>
|
204
205
|
|
205
206
|
<div class="method-description">
|
206
207
|
<p>
|
207
|
-
Converts a <a href="URI.html#
|
208
|
-
href="URI.html">URI</a>. If the <a href="URI.html#
|
208
|
+
Converts a <a href="URI.html#M000030">path</a> to a file protocol <a
|
209
|
+
href="URI.html">URI</a>. If the <a href="URI.html#M000030">path</a>
|
209
210
|
supplied is relative, it will be returned as a relative <a
|
210
|
-
href="URI.html">URI</a>. If the <a href="URI.html#
|
211
|
+
href="URI.html">URI</a>. If the <a href="URI.html#M000030">path</a>
|
211
212
|
supplied is actually a <a href="URI.html">URI</a>, it will return the
|
212
213
|
parsed <a href="URI.html">URI</a>.
|
213
214
|
</p>
|
214
215
|
<p><a class="source-toggle" href="#"
|
215
|
-
onclick="toggleCode('
|
216
|
-
<div class="method-source-code" id="
|
216
|
+
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
217
|
+
<div class="method-source-code" id="M000003-source">
|
217
218
|
<pre>
|
218
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
219
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 144</span>
|
220
|
+
144: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">convert_path</span>(<span class="ruby-identifier">path</span>)
|
221
|
+
145: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">nil?</span>
|
222
|
+
146:
|
223
|
+
147: <span class="ruby-identifier">converted_uri</span> = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">strip</span>
|
224
|
+
148: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">converted_uri</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"/"</span>
|
225
|
+
149: <span class="ruby-identifier">converted_uri</span> = <span class="ruby-value str">"file://"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">converted_uri</span>
|
226
|
+
150: <span class="ruby-keyword kw">end</span>
|
227
|
+
151: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span> <span class="ruby-operator">&&</span>
|
228
|
+
152: <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^[a-zA-Z]:[\\\/]/</span>).<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
229
|
+
153: <span class="ruby-identifier">converted_uri</span> = <span class="ruby-value str">"file:///"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">converted_uri</span>
|
230
|
+
154: <span class="ruby-keyword kw">end</span>
|
231
|
+
155: <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/^file:\/*/i</span>, <span class="ruby-value str">"file:///"</span>)
|
232
|
+
156: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">converted_uri</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^file:/i</span>
|
233
|
+
157: <span class="ruby-comment cmt"># Adjust windows-style uris</span>
|
234
|
+
158: <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/^file:\/\/\/([a-zA-Z])\|/i</span>, <span class="ruby-value str">'file:///\1:'</span>)
|
235
|
+
159: <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\\/</span>, <span class="ruby-value str">'/'</span>)
|
236
|
+
160: <span class="ruby-identifier">converted_uri</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">converted_uri</span>).<span class="ruby-identifier">normalize</span>
|
237
|
+
161: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">path</span>) <span class="ruby-operator">&&</span>
|
238
|
+
162: <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">path</span>).<span class="ruby-identifier">directory?</span>
|
239
|
+
163: <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\/$/</span>, <span class="ruby-value str">""</span>)
|
240
|
+
164: <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">path</span> = <span class="ruby-identifier">converted_uri</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'/'</span>
|
241
|
+
165: <span class="ruby-keyword kw">end</span>
|
242
|
+
166: <span class="ruby-keyword kw">else</span>
|
243
|
+
167: <span class="ruby-identifier">converted_uri</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">converted_uri</span>)
|
244
|
+
168: <span class="ruby-keyword kw">end</span>
|
245
|
+
169:
|
246
|
+
170: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">converted_uri</span>
|
247
|
+
171: <span class="ruby-keyword kw">end</span>
|
247
248
|
</pre>
|
248
249
|
</div>
|
249
250
|
</div>
|
250
251
|
</div>
|
251
252
|
|
252
|
-
<div id="method-
|
253
|
-
<a name="
|
253
|
+
<div id="method-M000009" class="method-detail">
|
254
|
+
<a name="M000009"></a>
|
254
255
|
|
255
256
|
<div class="method-heading">
|
256
|
-
<a href="#
|
257
|
+
<a href="#M000009" class="method-signature">
|
257
258
|
<span class="method-name">encode</span><span class="method-args">(uri)</span>
|
258
259
|
</a>
|
259
260
|
</div>
|
@@ -264,41 +265,41 @@ Percent encodes any special characters in the <a href="URI.html">URI</a>.
|
|
264
265
|
This method does not take IRIs or IDNs into account.
|
265
266
|
</p>
|
266
267
|
<p><a class="source-toggle" href="#"
|
267
|
-
onclick="toggleCode('
|
268
|
-
<div class="method-source-code" id="
|
268
|
+
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
269
|
+
<div class="method-source-code" id="M000009-source">
|
269
270
|
<pre>
|
270
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
271
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 354</span>
|
272
|
+
354: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode</span>(<span class="ruby-identifier">uri</span>)
|
273
|
+
355: <span class="ruby-identifier">uri_object</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">uri</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>)
|
274
|
+
356: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
|
275
|
+
357: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">scheme</span>,
|
276
|
+
358: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">SCHEME</span>),
|
277
|
+
359: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">user</span>,
|
278
|
+
360: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">AUTHORITY</span>),
|
279
|
+
361: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">password</span>,
|
280
|
+
362: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">AUTHORITY</span>),
|
281
|
+
363: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">host</span>,
|
282
|
+
364: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">AUTHORITY</span>),
|
283
|
+
365: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">specified_port</span>,
|
284
|
+
366: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">AUTHORITY</span>),
|
285
|
+
367: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">path</span>,
|
286
|
+
368: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH</span>),
|
287
|
+
369: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">query</span>,
|
288
|
+
370: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">QUERY</span>),
|
289
|
+
371: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">fragment</span>,
|
290
|
+
372: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">FRAGMENT</span>)
|
291
|
+
373: ).<span class="ruby-identifier">to_s</span>
|
292
|
+
374: <span class="ruby-keyword kw">end</span>
|
292
293
|
</pre>
|
293
294
|
</div>
|
294
295
|
</div>
|
295
296
|
</div>
|
296
297
|
|
297
|
-
<div id="method-
|
298
|
-
<a name="
|
298
|
+
<div id="method-M000007" class="method-detail">
|
299
|
+
<a name="M000007"></a>
|
299
300
|
|
300
301
|
<div class="method-heading">
|
301
|
-
<a href="#
|
302
|
+
<a href="#M000007" class="method-signature">
|
302
303
|
<span class="method-name">encode_segment</span><span class="method-args">(segment, character_class= Addressable::URI::CharacterClasses::RESERVED + Addressable::URI::CharacterClasses::UNRESERVED)</span>
|
303
304
|
</a>
|
304
305
|
</div>
|
@@ -322,30 +323,30 @@ An example:
|
|
322
323
|
=> "simple%2Dex%61mple"
|
323
324
|
</pre>
|
324
325
|
<p><a class="source-toggle" href="#"
|
325
|
-
onclick="toggleCode('
|
326
|
-
<div class="method-source-code" id="
|
326
|
+
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
327
|
+
<div class="method-source-code" id="M000007-source">
|
327
328
|
<pre>
|
328
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
329
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 332</span>
|
330
|
+
332: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segment</span>, <span class="ruby-identifier">character_class</span>=
|
331
|
+
333: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">RESERVED</span> <span class="ruby-operator">+</span>
|
332
|
+
334: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">UNRESERVED</span>)
|
333
|
+
335: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">segment</span>.<span class="ruby-identifier">nil?</span>
|
334
|
+
336: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">segment</span>.<span class="ruby-identifier">gsub</span>(
|
335
|
+
337: <span class="ruby-node">/[^#{character_class}]/</span>
|
336
|
+
338: ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">sequence</span><span class="ruby-operator">|</span>
|
337
|
+
339: (<span class="ruby-value str">"%"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">sequence</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">'C'</span>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">to_s</span>(<span class="ruby-value">16</span>).<span class="ruby-identifier">upcase</span>)
|
338
|
+
340: <span class="ruby-keyword kw">end</span>
|
339
|
+
341: <span class="ruby-keyword kw">end</span>
|
339
340
|
</pre>
|
340
341
|
</div>
|
341
342
|
</div>
|
342
343
|
</div>
|
343
344
|
|
344
|
-
<div id="method-
|
345
|
-
<a name="
|
345
|
+
<div id="method-M000004" class="method-detail">
|
346
|
+
<a name="M000004"></a>
|
346
347
|
|
347
348
|
<div class="method-heading">
|
348
|
-
<a href="#
|
349
|
+
<a href="#M000004" class="method-signature">
|
349
350
|
<span class="method-name">expand_template</span><span class="method-args">(pattern, mapping, processor=nil)</span>
|
350
351
|
</a>
|
351
352
|
</div>
|
@@ -386,47 +387,47 @@ An example:
|
|
386
387
|
=> "http://example.com/search/an+example+search+query/"
|
387
388
|
</pre>
|
388
389
|
<p><a class="source-toggle" href="#"
|
389
|
-
onclick="toggleCode('
|
390
|
-
<div class="method-source-code" id="
|
390
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
391
|
+
<div class="method-source-code" id="M000004-source">
|
391
392
|
<pre>
|
392
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
393
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 202</span>
|
394
|
+
202: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">expand_template</span>(<span class="ruby-identifier">pattern</span>, <span class="ruby-identifier">mapping</span>, <span class="ruby-identifier">processor</span>=<span class="ruby-keyword kw">nil</span>)
|
395
|
+
203: <span class="ruby-identifier">result</span> = <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">dup</span>
|
396
|
+
204: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">mapping</span>
|
397
|
+
205: <span class="ruby-identifier">transformed_value</span> = <span class="ruby-identifier">value</span>
|
398
|
+
206: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">processor</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
399
|
+
207: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">processor</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:validate</span>)
|
400
|
+
208: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">processor</span>.<span class="ruby-identifier">validate</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
|
401
|
+
209: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidTemplateValue</span>,
|
402
|
+
210: <span class="ruby-node">"(#{name}, #{value}) is an invalid template value."</span>
|
403
|
+
211: <span class="ruby-keyword kw">end</span>
|
404
|
+
212: <span class="ruby-keyword kw">end</span>
|
405
|
+
213: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">processor</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:transform</span>)
|
406
|
+
214: <span class="ruby-identifier">transformed_value</span> = <span class="ruby-identifier">processor</span>.<span class="ruby-identifier">transform</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
|
407
|
+
215: <span class="ruby-keyword kw">end</span>
|
408
|
+
216: <span class="ruby-keyword kw">end</span>
|
409
|
+
217:
|
410
|
+
218: <span class="ruby-comment cmt"># Handle percent escaping</span>
|
411
|
+
219: <span class="ruby-identifier">transformed_value</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">transformed_value</span>,
|
412
|
+
220: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">RESERVED</span> <span class="ruby-operator">+</span>
|
413
|
+
221: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">UNRESERVED</span>)
|
414
|
+
222:
|
415
|
+
223: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-node">/\{#{Regexp.escape(name)}\}/</span>, <span class="ruby-identifier">transformed_value</span>)
|
416
|
+
224: <span class="ruby-keyword kw">end</span>
|
417
|
+
225: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">gsub!</span>(
|
418
|
+
226: <span class="ruby-node">/\{[#{Addressable::URI::CharacterClasses::UNRESERVED}]+\}/</span>, <span class="ruby-value str">""</span>)
|
419
|
+
227: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">result</span>)
|
420
|
+
228: <span class="ruby-keyword kw">end</span>
|
420
421
|
</pre>
|
421
422
|
</div>
|
422
423
|
</div>
|
423
424
|
</div>
|
424
425
|
|
425
|
-
<div id="method-
|
426
|
-
<a name="
|
426
|
+
<div id="method-M000011" class="method-detail">
|
427
|
+
<a name="M000011"></a>
|
427
428
|
|
428
429
|
<div class="method-heading">
|
429
|
-
<a href="#
|
430
|
+
<a href="#M000011" class="method-signature">
|
430
431
|
<span class="method-name">extract</span><span class="method-args">(text, options={})</span>
|
431
432
|
</a>
|
432
433
|
</div>
|
@@ -436,71 +437,131 @@ An example:
|
|
436
437
|
Extracts uris from an arbitrary body of text.
|
437
438
|
</p>
|
438
439
|
<p><a class="source-toggle" href="#"
|
439
|
-
onclick="toggleCode('
|
440
|
-
<div class="method-source-code" id="
|
440
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
441
|
+
<div class="method-source-code" id="M000011-source">
|
441
442
|
<pre>
|
442
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
443
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 420</span>
|
444
|
+
420: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">extract</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">options</span>={})
|
445
|
+
421: <span class="ruby-identifier">defaults</span> = {<span class="ruby-identifier">:base</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">:parse</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">false</span>}
|
446
|
+
422: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
|
447
|
+
423: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidOptionError</span> <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">options</span>.<span class="ruby-identifier">keys</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">keys</span>).<span class="ruby-identifier">empty?</span>
|
448
|
+
424: <span class="ruby-comment cmt"># This regular expression needs to be less forgiving or else it would</span>
|
449
|
+
425: <span class="ruby-comment cmt"># match virtually all text. Which isn't exactly what we're going for.</span>
|
450
|
+
426: <span class="ruby-identifier">extract_regex</span> = <span class="ruby-regexp re">/((([a-z\+]+):)[^ \n\<\>\"\\]+[\w\/])/</span>
|
451
|
+
427: <span class="ruby-identifier">extracted_uris</span> =
|
452
|
+
428: <span class="ruby-identifier">text</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">extract_regex</span>).<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span> <span class="ruby-identifier">match</span>[<span class="ruby-value">0</span>] }
|
453
|
+
429: <span class="ruby-identifier">sgml_extract_regex</span> = <span class="ruby-regexp re">/<[^>]+href=\"([^\"]+?)\"[^>]*>/</span>
|
454
|
+
430: <span class="ruby-identifier">sgml_extracted_uris</span> =
|
455
|
+
431: <span class="ruby-identifier">text</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">sgml_extract_regex</span>).<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span> <span class="ruby-identifier">match</span>[<span class="ruby-value">0</span>] }
|
456
|
+
432: <span class="ruby-identifier">extracted_uris</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">sgml_extracted_uris</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">extracted_uris</span>)
|
457
|
+
433: <span class="ruby-identifier">textile_extract_regex</span> = <span class="ruby-regexp re">/\".+?\":([^ ]+\/[^ ]+)[ \,\.\;\:\?\!\<\>\"]/i</span>
|
458
|
+
434: <span class="ruby-identifier">textile_extracted_uris</span> =
|
459
|
+
435: <span class="ruby-identifier">text</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">textile_extract_regex</span>).<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">match</span><span class="ruby-operator">|</span> <span class="ruby-identifier">match</span>[<span class="ruby-value">0</span>] }
|
460
|
+
436: <span class="ruby-identifier">extracted_uris</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">textile_extracted_uris</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">extracted_uris</span>)
|
461
|
+
437: <span class="ruby-identifier">parsed_uris</span> = []
|
462
|
+
438: <span class="ruby-identifier">base_uri</span> = <span class="ruby-keyword kw">nil</span>
|
463
|
+
439: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:base</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
464
|
+
440: <span class="ruby-identifier">base_uri</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:base</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:base</span>].<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>)
|
465
|
+
441: <span class="ruby-identifier">base_uri</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:base</span>].<span class="ruby-identifier">to_s</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">base_uri</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
|
466
|
+
442: <span class="ruby-keyword kw">end</span>
|
467
|
+
443: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">uri_string</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">extracted_uris</span>
|
468
|
+
444: <span class="ruby-keyword kw">begin</span>
|
469
|
+
445: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">base_uri</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
|
470
|
+
446: <span class="ruby-identifier">parsed_uris</span> <span class="ruby-operator"><<</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri_string</span>)
|
471
|
+
447: <span class="ruby-keyword kw">else</span>
|
472
|
+
448: <span class="ruby-identifier">parsed_uris</span> <span class="ruby-operator"><<</span> (<span class="ruby-identifier">base_uri</span> <span class="ruby-operator">+</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri_string</span>))
|
473
|
+
449: <span class="ruby-keyword kw">end</span>
|
474
|
+
450: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
|
475
|
+
451: <span class="ruby-keyword kw">nil</span>
|
476
|
+
452: <span class="ruby-keyword kw">end</span>
|
477
|
+
453: <span class="ruby-keyword kw">end</span>
|
478
|
+
454: <span class="ruby-identifier">parsed_uris</span>.<span class="ruby-identifier">reject!</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">uri</span><span class="ruby-operator">|</span>
|
479
|
+
455: (<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/T\d+/</span> <span class="ruby-operator">||</span>
|
480
|
+
456: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"xmlns"</span> <span class="ruby-operator">||</span>
|
481
|
+
457: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"xml"</span> <span class="ruby-operator">||</span>
|
482
|
+
458: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"thr"</span> <span class="ruby-operator">||</span>
|
483
|
+
459: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"this"</span> <span class="ruby-operator">||</span>
|
484
|
+
460: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"float"</span> <span class="ruby-operator">||</span>
|
485
|
+
461: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"user"</span> <span class="ruby-operator">||</span>
|
486
|
+
462: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"username"</span> <span class="ruby-operator">||</span>
|
487
|
+
463: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"out"</span>)
|
488
|
+
464: <span class="ruby-keyword kw">end</span>
|
489
|
+
465: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:parse</span>]
|
490
|
+
466: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">parsed_uris</span>
|
491
|
+
467: <span class="ruby-keyword kw">else</span>
|
492
|
+
468: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">parsed_uris</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">uri</span><span class="ruby-operator">|</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span> }
|
493
|
+
469: <span class="ruby-keyword kw">end</span>
|
494
|
+
470: <span class="ruby-keyword kw">end</span>
|
494
495
|
</pre>
|
495
496
|
</div>
|
496
497
|
</div>
|
497
498
|
</div>
|
498
499
|
|
499
|
-
<div id="method-
|
500
|
-
<a name="
|
500
|
+
<div id="method-M000002" class="method-detail">
|
501
|
+
<a name="M000002"></a>
|
501
502
|
|
502
503
|
<div class="method-heading">
|
503
|
-
<a href="#
|
504
|
+
<a href="#M000002" class="method-signature">
|
505
|
+
<span class="method-name">heuristic_parse</span><span class="method-args">(input, hints={})</span>
|
506
|
+
</a>
|
507
|
+
</div>
|
508
|
+
|
509
|
+
<div class="method-description">
|
510
|
+
<p>
|
511
|
+
Converts an input to a <a href="URI.html">URI</a>. The input does not have
|
512
|
+
to be a valid <a href="URI.html">URI</a> — the method will use
|
513
|
+
heuristics to guess what <a href="URI.html">URI</a> was intended. This is
|
514
|
+
not standards compliant, merely <a
|
515
|
+
href="URI.html#M000015">user</a>-friendly.
|
516
|
+
</p>
|
517
|
+
<p><a class="source-toggle" href="#"
|
518
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
519
|
+
<div class="method-source-code" id="M000002-source">
|
520
|
+
<pre>
|
521
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 107</span>
|
522
|
+
107: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">heuristic_parse</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">hints</span>={})
|
523
|
+
108: <span class="ruby-identifier">input</span> = <span class="ruby-identifier">input</span>.<span class="ruby-identifier">dup</span>
|
524
|
+
109: <span class="ruby-identifier">hints</span> = {
|
525
|
+
110: <span class="ruby-identifier">:scheme</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"http"</span>
|
526
|
+
111: }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">hints</span>)
|
527
|
+
112: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">input</span>
|
528
|
+
113: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^http:\/+/</span>
|
529
|
+
114: <span class="ruby-identifier">input</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/^http:\/+/</span>, <span class="ruby-value str">"http://"</span>)
|
530
|
+
115: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^feed:\/+http:\/+/</span>
|
531
|
+
116: <span class="ruby-identifier">input</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/^feed:\/+http:\/+/</span>, <span class="ruby-value str">"feed:http://"</span>)
|
532
|
+
117: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^feed:\/+/</span>
|
533
|
+
118: <span class="ruby-identifier">input</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/^feed:\/+/</span>, <span class="ruby-value str">"feed://"</span>)
|
534
|
+
119: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^file:\/+/</span>
|
535
|
+
120: <span class="ruby-identifier">input</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/^file:\/+/</span>, <span class="ruby-value str">"file:///"</span>)
|
536
|
+
121: <span class="ruby-keyword kw">end</span>
|
537
|
+
122: <span class="ruby-identifier">parsed</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">input</span>)
|
538
|
+
123: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parsed</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^[^\/?#\.]+\.[^\/?#]+$/</span>
|
539
|
+
124: <span class="ruby-identifier">parsed</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">hints</span>[<span class="ruby-identifier">:scheme</span>] <span class="ruby-operator">+</span> <span class="ruby-value str">"://"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">input</span>)
|
540
|
+
125: <span class="ruby-keyword kw">end</span>
|
541
|
+
126: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parsed</span>.<span class="ruby-identifier">authority</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
|
542
|
+
127: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parsed</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^[^\/]+\./</span>
|
543
|
+
128: <span class="ruby-identifier">new_host</span> = <span class="ruby-identifier">parsed</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^([^\/]+\.[^\/]*)/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
|
544
|
+
129: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">new_host</span>
|
545
|
+
130: <span class="ruby-identifier">new_path</span> = <span class="ruby-identifier">parsed</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub</span>(
|
546
|
+
131: <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"^"</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">new_host</span>)), <span class="ruby-value str">""</span>)
|
547
|
+
132: <span class="ruby-identifier">parsed</span>.<span class="ruby-identifier">host</span> = <span class="ruby-identifier">new_host</span>
|
548
|
+
133: <span class="ruby-identifier">parsed</span>.<span class="ruby-identifier">path</span> = <span class="ruby-identifier">new_path</span>
|
549
|
+
134: <span class="ruby-identifier">parsed</span>.<span class="ruby-identifier">scheme</span> = <span class="ruby-identifier">hints</span>[<span class="ruby-identifier">:scheme</span>]
|
550
|
+
135: <span class="ruby-keyword kw">end</span>
|
551
|
+
136: <span class="ruby-keyword kw">end</span>
|
552
|
+
137: <span class="ruby-keyword kw">end</span>
|
553
|
+
138: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">parsed</span>
|
554
|
+
139: <span class="ruby-keyword kw">end</span>
|
555
|
+
</pre>
|
556
|
+
</div>
|
557
|
+
</div>
|
558
|
+
</div>
|
559
|
+
|
560
|
+
<div id="method-M000025" class="method-detail">
|
561
|
+
<a name="M000025"></a>
|
562
|
+
|
563
|
+
<div class="method-heading">
|
564
|
+
<a href="#M000025" class="method-signature">
|
504
565
|
<span class="method-name">ip_based_schemes</span><span class="method-args">()</span>
|
505
566
|
</a>
|
506
567
|
</div>
|
@@ -509,30 +570,30 @@ Extracts uris from an arbitrary body of text.
|
|
509
570
|
<p>
|
510
571
|
Returns an array of known ip-based schemes. These schemes typically use a
|
511
572
|
similar <a href="URI.html">URI</a> form: //<<a
|
512
|
-
href="URI.html#
|
513
|
-
href="URI.html#
|
514
|
-
href="URI.html#
|
515
|
-
href="URI.html#
|
516
|
-
href="URI.html#
|
573
|
+
href="URI.html#M000015">user</a>>:<<a
|
574
|
+
href="URI.html#M000017">password</a>>@<<a
|
575
|
+
href="URI.html#M000021">host</a>>:<<a
|
576
|
+
href="URI.html#M000027">port</a>>/<url-<a
|
577
|
+
href="URI.html#M000030">path</a>>
|
517
578
|
</p>
|
518
579
|
<p><a class="source-toggle" href="#"
|
519
|
-
onclick="toggleCode('
|
520
|
-
<div class="method-source-code" id="
|
580
|
+
onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
|
581
|
+
<div class="method-source-code" id="M000025-source">
|
521
582
|
<pre>
|
522
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
523
|
-
|
524
|
-
|
525
|
-
|
583
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 643</span>
|
584
|
+
643: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">ip_based_schemes</span>
|
585
|
+
644: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme_mapping</span>.<span class="ruby-identifier">keys</span>
|
586
|
+
645: <span class="ruby-keyword kw">end</span>
|
526
587
|
</pre>
|
527
588
|
</div>
|
528
589
|
</div>
|
529
590
|
</div>
|
530
591
|
|
531
|
-
<div id="method-
|
532
|
-
<a name="
|
592
|
+
<div id="method-M000006" class="method-detail">
|
593
|
+
<a name="M000006"></a>
|
533
594
|
|
534
595
|
<div class="method-heading">
|
535
|
-
<a href="#
|
596
|
+
<a href="#M000006" class="method-signature">
|
536
597
|
<span class="method-name">join</span><span class="method-args">(*uris)</span>
|
537
598
|
</a>
|
538
599
|
</div>
|
@@ -542,75 +603,74 @@ href="URI.html#M000029">path</a>>
|
|
542
603
|
Joins several uris together.
|
543
604
|
</p>
|
544
605
|
<p><a class="source-toggle" href="#"
|
545
|
-
onclick="toggleCode('
|
546
|
-
<div class="method-source-code" id="
|
606
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
607
|
+
<div class="method-source-code" id="M000006-source">
|
547
608
|
<pre>
|
548
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
609
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 309</span>
|
610
|
+
309: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">join</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">uris</span>)
|
611
|
+
310: <span class="ruby-identifier">uri_objects</span> = <span class="ruby-identifier">uris</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">uri</span><span class="ruby-operator">|</span>
|
612
|
+
311: <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">uri</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>)
|
613
|
+
312: <span class="ruby-keyword kw">end</span>
|
614
|
+
313: <span class="ruby-identifier">result</span> = <span class="ruby-identifier">uri_objects</span>.<span class="ruby-identifier">shift</span>.<span class="ruby-identifier">dup</span>
|
615
|
+
314: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">uri</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">uri_objects</span>
|
616
|
+
315: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">uri</span>)
|
617
|
+
316: <span class="ruby-keyword kw">end</span>
|
618
|
+
317: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
|
619
|
+
318: <span class="ruby-keyword kw">end</span>
|
559
620
|
</pre>
|
560
621
|
</div>
|
561
622
|
</div>
|
562
623
|
</div>
|
563
624
|
|
564
|
-
<div id="method-
|
565
|
-
<a name="
|
625
|
+
<div id="method-M000012" class="method-detail">
|
626
|
+
<a name="M000012"></a>
|
566
627
|
|
567
628
|
<div class="method-heading">
|
568
|
-
<a href="#
|
629
|
+
<a href="#M000012" class="method-signature">
|
569
630
|
<span class="method-name">new</span><span class="method-args">(scheme, user, password, host, port, path, query, fragment)</span>
|
570
631
|
</a>
|
571
632
|
</div>
|
572
633
|
|
573
634
|
<div class="method-description">
|
574
635
|
<p>
|
575
|
-
Creates a <a href="URI.html#
|
636
|
+
Creates a <a href="URI.html#M000012">new</a> uri object from component
|
576
637
|
parts. Passing nil for any of these parameters is acceptable.
|
577
638
|
</p>
|
578
639
|
<p><a class="source-toggle" href="#"
|
579
|
-
onclick="toggleCode('
|
580
|
-
<div class="method-source-code" id="
|
640
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
641
|
+
<div class="method-source-code" id="M000012-source">
|
581
642
|
<pre>
|
582
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
474: <span class="ruby-keyword kw">end</span>
|
643
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 474</span>
|
644
|
+
474: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">scheme</span>, <span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>, <span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">query</span>, <span class="ruby-identifier">fragment</span>)
|
645
|
+
475: <span class="ruby-ivar">@scheme</span> = <span class="ruby-identifier">scheme</span>
|
646
|
+
476: <span class="ruby-ivar">@scheme</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@scheme</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">strip</span> <span class="ruby-operator">==</span> <span class="ruby-value str">""</span>
|
647
|
+
477: <span class="ruby-ivar">@user</span> = <span class="ruby-identifier">user</span>
|
648
|
+
478: <span class="ruby-ivar">@password</span> = <span class="ruby-identifier">password</span>
|
649
|
+
479: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
|
650
|
+
480: <span class="ruby-ivar">@specified_port</span> = <span class="ruby-identifier">port</span>.<span class="ruby-identifier">to_s</span>
|
651
|
+
481: <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">port</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Fixnum</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">port</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">port</span>
|
652
|
+
482: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@port</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span>(<span class="ruby-ivar">@port</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^\d+$/</span>)
|
653
|
+
483: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>,
|
654
|
+
484: <span class="ruby-node">"Invalid port number: #{@port.inspect}"</span>
|
655
|
+
485: <span class="ruby-keyword kw">end</span>
|
656
|
+
486: <span class="ruby-ivar">@port</span> = <span class="ruby-ivar">@port</span>.<span class="ruby-identifier">to_i</span>
|
657
|
+
487: <span class="ruby-ivar">@port</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@port</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
658
|
+
488: <span class="ruby-ivar">@path</span> = (<span class="ruby-identifier">path</span> <span class="ruby-operator">||</span> <span class="ruby-value str">""</span>)
|
659
|
+
489: <span class="ruby-ivar">@query</span> = <span class="ruby-identifier">query</span>
|
660
|
+
490: <span class="ruby-ivar">@fragment</span> = <span class="ruby-identifier">fragment</span>
|
661
|
+
491:
|
662
|
+
492: <span class="ruby-identifier">validate</span>()
|
663
|
+
493: <span class="ruby-keyword kw">end</span>
|
604
664
|
</pre>
|
605
665
|
</div>
|
606
666
|
</div>
|
607
667
|
</div>
|
608
668
|
|
609
|
-
<div id="method-
|
610
|
-
<a name="
|
669
|
+
<div id="method-M000010" class="method-detail">
|
670
|
+
<a name="M000010"></a>
|
611
671
|
|
612
672
|
<div class="method-heading">
|
613
|
-
<a href="#
|
673
|
+
<a href="#M000010" class="method-signature">
|
614
674
|
<span class="method-name">normalized_encode</span><span class="method-args">(uri)</span>
|
615
675
|
</a>
|
616
676
|
</div>
|
@@ -622,46 +682,46 @@ a hostname are not percent encoded to allow for internationalized domain
|
|
622
682
|
names.
|
623
683
|
</p>
|
624
684
|
<p><a class="source-toggle" href="#"
|
625
|
-
onclick="toggleCode('
|
626
|
-
<div class="method-source-code" id="
|
685
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
686
|
+
<div class="method-source-code" id="M000010-source">
|
627
687
|
<pre>
|
628
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
688
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 382</span>
|
689
|
+
382: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalized_encode</span>(<span class="ruby-identifier">uri</span>)
|
690
|
+
383: <span class="ruby-identifier">uri_object</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">uri</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>)
|
691
|
+
384: <span class="ruby-identifier">segments</span> = {
|
692
|
+
385: <span class="ruby-identifier">:scheme</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">scheme</span>),
|
693
|
+
386: <span class="ruby-identifier">:user</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">user</span>),
|
694
|
+
387: <span class="ruby-identifier">:password</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">password</span>),
|
695
|
+
388: <span class="ruby-identifier">:host</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">host</span>),
|
696
|
+
389: <span class="ruby-identifier">:port</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">specified_port</span>),
|
697
|
+
390: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">path</span>),
|
698
|
+
391: <span class="ruby-identifier">:query</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">query</span>),
|
699
|
+
392: <span class="ruby-identifier">:fragment</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">uri_object</span>.<span class="ruby-identifier">fragment</span>)
|
700
|
+
393: }
|
701
|
+
394: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">IDNA</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:use_libidn?</span>)
|
702
|
+
395: <span class="ruby-identifier">segments</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
703
|
+
396: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
704
|
+
397: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-constant">IDN</span><span class="ruby-operator">::</span><span class="ruby-constant">Stringprep</span>.<span class="ruby-identifier">nfkc_normalize</span>(<span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>)
|
705
|
+
398: <span class="ruby-keyword kw">end</span>
|
706
|
+
399: <span class="ruby-keyword kw">end</span>
|
707
|
+
400: <span class="ruby-keyword kw">end</span>
|
708
|
+
401: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
|
709
|
+
402: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>],
|
710
|
+
403: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">SCHEME</span>),
|
711
|
+
404: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:user</span>],
|
712
|
+
405: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">AUTHORITY</span>),
|
713
|
+
406: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:password</span>],
|
714
|
+
407: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">AUTHORITY</span>),
|
715
|
+
408: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:host</span>],
|
716
|
+
409: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:port</span>],
|
717
|
+
410: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:path</span>],
|
718
|
+
411: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH</span>),
|
719
|
+
412: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:query</span>],
|
720
|
+
413: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">QUERY</span>),
|
721
|
+
414: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">encode_segment</span>(<span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:fragment</span>],
|
722
|
+
415: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">CharacterClasses</span><span class="ruby-operator">::</span><span class="ruby-constant">FRAGMENT</span>)
|
723
|
+
416: ).<span class="ruby-identifier">to_s</span>
|
724
|
+
417: <span class="ruby-keyword kw">end</span>
|
665
725
|
</pre>
|
666
726
|
</div>
|
667
727
|
</div>
|
@@ -721,40 +781,23 @@ Returns a <a href="URI.html">URI</a> object based on the parsed string.
|
|
721
781
|
93: <span class="ruby-identifier">host</span> = <span class="ruby-identifier">authority</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/^([^\[\]]*)@/</span>, <span class="ruby-value str">""</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/:([^:@\[\]]*?)$/</span>, <span class="ruby-value str">""</span>)
|
722
782
|
94: <span class="ruby-identifier">port</span> = <span class="ruby-identifier">authority</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/:([^:@\[\]]*?)$/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
|
723
783
|
95: <span class="ruby-keyword kw">end</span>
|
724
|
-
96: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">port</span
|
784
|
+
96: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">port</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">port</span> <span class="ruby-operator">==</span> <span class="ruby-value str">""</span>
|
725
785
|
97: <span class="ruby-identifier">port</span> = <span class="ruby-keyword kw">nil</span>
|
726
786
|
98: <span class="ruby-keyword kw">end</span>
|
727
787
|
99:
|
728
|
-
100: <span class="ruby-
|
729
|
-
101:
|
730
|
-
102:
|
731
|
-
103: <span class="ruby-comment cmt"># Special exception for dealing with the retarded idea of the</span>
|
732
|
-
104: <span class="ruby-comment cmt"># feed pseudo-protocol. Without this exception, the parser will read</span>
|
733
|
-
105: <span class="ruby-comment cmt"># the URI as having a blank port number, instead of as having a second</span>
|
734
|
-
106: <span class="ruby-comment cmt"># URI embedded within. This exception translates these broken URIs</span>
|
735
|
-
107: <span class="ruby-comment cmt"># and instead treats the inner URI as opaque.</span>
|
736
|
-
108: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"feed"</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">host</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"http"</span>
|
737
|
-
109: <span class="ruby-identifier">userinfo</span> = <span class="ruby-keyword kw">nil</span>
|
738
|
-
110: <span class="ruby-identifier">user</span> = <span class="ruby-keyword kw">nil</span>
|
739
|
-
111: <span class="ruby-identifier">password</span> = <span class="ruby-keyword kw">nil</span>
|
740
|
-
112: <span class="ruby-identifier">host</span> = <span class="ruby-keyword kw">nil</span>
|
741
|
-
113: <span class="ruby-identifier">port</span> = <span class="ruby-keyword kw">nil</span>
|
742
|
-
114: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">authority</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">path</span>
|
743
|
-
115: <span class="ruby-keyword kw">end</span>
|
744
|
-
116:
|
745
|
-
117: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
|
746
|
-
118: <span class="ruby-identifier">scheme</span>, <span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>, <span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">query</span>, <span class="ruby-identifier">fragment</span>)
|
747
|
-
119: <span class="ruby-keyword kw">end</span>
|
788
|
+
100: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
|
789
|
+
101: <span class="ruby-identifier">scheme</span>, <span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>, <span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">query</span>, <span class="ruby-identifier">fragment</span>)
|
790
|
+
102: <span class="ruby-keyword kw">end</span>
|
748
791
|
</pre>
|
749
792
|
</div>
|
750
793
|
</div>
|
751
794
|
</div>
|
752
795
|
|
753
|
-
<div id="method-
|
754
|
-
<a name="
|
796
|
+
<div id="method-M000026" class="method-detail">
|
797
|
+
<a name="M000026"></a>
|
755
798
|
|
756
799
|
<div class="method-heading">
|
757
|
-
<a href="#
|
800
|
+
<a href="#M000026" class="method-signature">
|
758
801
|
<span class="method-name">scheme_mapping</span><span class="method-args">()</span>
|
759
802
|
</a>
|
760
803
|
</div>
|
@@ -762,44 +805,44 @@ Returns a <a href="URI.html">URI</a> object based on the parsed string.
|
|
762
805
|
<div class="method-description">
|
763
806
|
<p>
|
764
807
|
Returns a hash of common IP-based schemes and their default <a
|
765
|
-
href="URI.html#
|
766
|
-
href="URI.html#
|
808
|
+
href="URI.html#M000027">port</a> numbers. Adding <a
|
809
|
+
href="URI.html#M000012">new</a> schemes to this hash, as necessary, will
|
767
810
|
allow for better <a href="URI.html">URI</a> normalization.
|
768
811
|
</p>
|
769
812
|
<p><a class="source-toggle" href="#"
|
770
|
-
onclick="toggleCode('
|
771
|
-
<div class="method-source-code" id="
|
813
|
+
onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
|
814
|
+
<div class="method-source-code" id="M000026-source">
|
772
815
|
<pre>
|
773
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
816
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 650</span>
|
817
|
+
650: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme_mapping</span>
|
818
|
+
651: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">defined?</span>(<span class="ruby-ivar">@protocol_mapping</span>) <span class="ruby-operator">||</span> <span class="ruby-ivar">@protocol_mapping</span>.<span class="ruby-identifier">nil?</span>
|
819
|
+
652: <span class="ruby-ivar">@protocol_mapping</span> = {
|
820
|
+
653: <span class="ruby-value str">"http"</span> =<span class="ruby-operator">></span> <span class="ruby-value">80</span>,
|
821
|
+
654: <span class="ruby-value str">"https"</span> =<span class="ruby-operator">></span> <span class="ruby-value">443</span>,
|
822
|
+
655: <span class="ruby-value str">"ftp"</span> =<span class="ruby-operator">></span> <span class="ruby-value">21</span>,
|
823
|
+
656: <span class="ruby-value str">"tftp"</span> =<span class="ruby-operator">></span> <span class="ruby-value">69</span>,
|
824
|
+
657: <span class="ruby-value str">"ssh"</span> =<span class="ruby-operator">></span> <span class="ruby-value">22</span>,
|
825
|
+
658: <span class="ruby-value str">"svn+ssh"</span> =<span class="ruby-operator">></span> <span class="ruby-value">22</span>,
|
826
|
+
659: <span class="ruby-value str">"telnet"</span> =<span class="ruby-operator">></span> <span class="ruby-value">23</span>,
|
827
|
+
660: <span class="ruby-value str">"nntp"</span> =<span class="ruby-operator">></span> <span class="ruby-value">119</span>,
|
828
|
+
661: <span class="ruby-value str">"gopher"</span> =<span class="ruby-operator">></span> <span class="ruby-value">70</span>,
|
829
|
+
662: <span class="ruby-value str">"wais"</span> =<span class="ruby-operator">></span> <span class="ruby-value">210</span>,
|
830
|
+
663: <span class="ruby-value str">"ldap"</span> =<span class="ruby-operator">></span> <span class="ruby-value">389</span>,
|
831
|
+
664: <span class="ruby-value str">"prospero"</span> =<span class="ruby-operator">></span> <span class="ruby-value">1525</span>
|
832
|
+
665: }
|
833
|
+
666: <span class="ruby-keyword kw">end</span>
|
834
|
+
667: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@protocol_mapping</span>
|
835
|
+
668: <span class="ruby-keyword kw">end</span>
|
793
836
|
</pre>
|
794
837
|
</div>
|
795
838
|
</div>
|
796
839
|
</div>
|
797
840
|
|
798
|
-
<div id="method-
|
799
|
-
<a name="
|
841
|
+
<div id="method-M000008" class="method-detail">
|
842
|
+
<a name="M000008"></a>
|
800
843
|
|
801
844
|
<div class="method-heading">
|
802
|
-
<a href="#
|
845
|
+
<a href="#M000008" class="method-signature">
|
803
846
|
<span class="method-name">unencode_segment</span><span class="method-args">(segment)</span>
|
804
847
|
</a>
|
805
848
|
</div>
|
@@ -810,16 +853,16 @@ Unencodes any percent encoded characters within a <a
|
|
810
853
|
href="URI.html">URI</a> segment. Returns a string.
|
811
854
|
</p>
|
812
855
|
<p><a class="source-toggle" href="#"
|
813
|
-
onclick="toggleCode('
|
814
|
-
<div class="method-source-code" id="
|
856
|
+
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
857
|
+
<div class="method-source-code" id="M000008-source">
|
815
858
|
<pre>
|
816
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
859
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 345</span>
|
860
|
+
345: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unencode_segment</span>(<span class="ruby-identifier">segment</span>)
|
861
|
+
346: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">segment</span>.<span class="ruby-identifier">nil?</span>
|
862
|
+
347: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">segment</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/%[0-9a-f]{2}/i</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">sequence</span><span class="ruby-operator">|</span>
|
863
|
+
348: <span class="ruby-identifier">sequence</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">3</span>].<span class="ruby-identifier">to_i</span>(<span class="ruby-value">16</span>).<span class="ruby-identifier">chr</span>
|
864
|
+
349: <span class="ruby-keyword kw">end</span>
|
865
|
+
350: <span class="ruby-keyword kw">end</span>
|
823
866
|
</pre>
|
824
867
|
</div>
|
825
868
|
</div>
|
@@ -827,11 +870,11 @@ href="URI.html">URI</a> segment. Returns a string.
|
|
827
870
|
|
828
871
|
<h3 class="section-bar">Public Instance methods</h3>
|
829
872
|
|
830
|
-
<div id="method-
|
831
|
-
<a name="
|
873
|
+
<div id="method-M000041" class="method-detail">
|
874
|
+
<a name="M000041"></a>
|
832
875
|
|
833
876
|
<div class="method-heading">
|
834
|
-
<a href="#
|
877
|
+
<a href="#M000041" class="method-signature">
|
835
878
|
<span class="method-name">+</span><span class="method-args">(uri)</span>
|
836
879
|
</a>
|
837
880
|
</div>
|
@@ -841,109 +884,109 @@ href="URI.html">URI</a> segment. Returns a string.
|
|
841
884
|
Joins two URIs together.
|
842
885
|
</p>
|
843
886
|
<p><a class="source-toggle" href="#"
|
844
|
-
onclick="toggleCode('
|
845
|
-
<div class="method-source-code" id="
|
887
|
+
onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
|
888
|
+
<div class="method-source-code" id="M000041-source">
|
846
889
|
<pre>
|
847
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
890
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 769</span>
|
891
|
+
769: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span>(<span class="ruby-identifier">uri</span>)
|
892
|
+
770: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>)
|
893
|
+
771: <span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>)
|
894
|
+
772: <span class="ruby-keyword kw">end</span>
|
895
|
+
773: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-value str">""</span>
|
896
|
+
774: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dup</span>
|
897
|
+
775: <span class="ruby-keyword kw">end</span>
|
898
|
+
776:
|
899
|
+
777: <span class="ruby-identifier">joined_scheme</span> = <span class="ruby-keyword kw">nil</span>
|
900
|
+
778: <span class="ruby-identifier">joined_user</span> = <span class="ruby-keyword kw">nil</span>
|
901
|
+
779: <span class="ruby-identifier">joined_password</span> = <span class="ruby-keyword kw">nil</span>
|
902
|
+
780: <span class="ruby-identifier">joined_host</span> = <span class="ruby-keyword kw">nil</span>
|
903
|
+
781: <span class="ruby-identifier">joined_port</span> = <span class="ruby-keyword kw">nil</span>
|
904
|
+
782: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">nil</span>
|
905
|
+
783: <span class="ruby-identifier">joined_query</span> = <span class="ruby-keyword kw">nil</span>
|
906
|
+
784: <span class="ruby-identifier">joined_fragment</span> = <span class="ruby-keyword kw">nil</span>
|
907
|
+
785:
|
908
|
+
786: <span class="ruby-comment cmt"># Section 5.2.2 of RFC 3986</span>
|
909
|
+
787: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
910
|
+
788: <span class="ruby-identifier">joined_scheme</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span>
|
911
|
+
789: <span class="ruby-identifier">joined_user</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">user</span>
|
912
|
+
790: <span class="ruby-identifier">joined_password</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">password</span>
|
913
|
+
791: <span class="ruby-identifier">joined_host</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>
|
914
|
+
792: <span class="ruby-identifier">joined_port</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">specified_port</span>
|
915
|
+
793: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>)
|
916
|
+
794: <span class="ruby-identifier">joined_query</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
|
917
|
+
795: <span class="ruby-keyword kw">else</span>
|
918
|
+
796: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">authority</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
919
|
+
797: <span class="ruby-identifier">joined_user</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">user</span>
|
920
|
+
798: <span class="ruby-identifier">joined_password</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">password</span>
|
921
|
+
799: <span class="ruby-identifier">joined_host</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>
|
922
|
+
800: <span class="ruby-identifier">joined_port</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">specified_port</span>
|
923
|
+
801: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>)
|
924
|
+
802: <span class="ruby-identifier">joined_query</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
|
925
|
+
803: <span class="ruby-keyword kw">else</span>
|
926
|
+
804: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-value str">""</span>
|
927
|
+
805: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>
|
928
|
+
806: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
929
|
+
807: <span class="ruby-identifier">joined_query</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
|
930
|
+
808: <span class="ruby-keyword kw">else</span>
|
931
|
+
809: <span class="ruby-identifier">joined_query</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>
|
932
|
+
810: <span class="ruby-keyword kw">end</span>
|
933
|
+
811: <span class="ruby-keyword kw">else</span>
|
934
|
+
812: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"/"</span>
|
935
|
+
813: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>)
|
936
|
+
814: <span class="ruby-keyword kw">else</span>
|
937
|
+
815: <span class="ruby-identifier">base_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">dup</span>
|
938
|
+
816: <span class="ruby-identifier">base_path</span> = <span class="ruby-value str">""</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">base_path</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
|
939
|
+
817: <span class="ruby-identifier">base_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">base_path</span>)
|
940
|
+
818:
|
941
|
+
819: <span class="ruby-comment cmt"># Section 5.2.3 of RFC 3986</span>
|
942
|
+
820: <span class="ruby-comment cmt">#</span>
|
943
|
+
821: <span class="ruby-comment cmt"># Removes the right-most path segment from the base path.</span>
|
944
|
+
822: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">base_path</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\//</span>
|
945
|
+
823: <span class="ruby-identifier">base_path</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\/[^\/]+$/</span>, <span class="ruby-value str">"/"</span>)
|
946
|
+
824: <span class="ruby-keyword kw">else</span>
|
947
|
+
825: <span class="ruby-identifier">base_path</span> = <span class="ruby-value str">""</span>
|
948
|
+
826: <span class="ruby-keyword kw">end</span>
|
949
|
+
827:
|
950
|
+
828: <span class="ruby-comment cmt"># If the base path is empty and an authority segment has been</span>
|
951
|
+
829: <span class="ruby-comment cmt"># defined, use a base path of "/"</span>
|
952
|
+
830: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">base_path</span> <span class="ruby-operator">==</span> <span class="ruby-value str">""</span> <span class="ruby-operator">&&</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">authority</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
953
|
+
831: <span class="ruby-identifier">base_path</span> = <span class="ruby-value str">"/"</span>
|
954
|
+
832: <span class="ruby-keyword kw">end</span>
|
955
|
+
833:
|
956
|
+
834: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">base_path</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>)
|
957
|
+
835: <span class="ruby-keyword kw">end</span>
|
958
|
+
836: <span class="ruby-identifier">joined_query</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
|
959
|
+
837: <span class="ruby-keyword kw">end</span>
|
960
|
+
838: <span class="ruby-identifier">joined_user</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span>
|
961
|
+
839: <span class="ruby-identifier">joined_password</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>
|
962
|
+
840: <span class="ruby-identifier">joined_host</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>
|
963
|
+
841: <span class="ruby-identifier">joined_port</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">specified_port</span>
|
964
|
+
842: <span class="ruby-keyword kw">end</span>
|
965
|
+
843: <span class="ruby-identifier">joined_scheme</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>
|
966
|
+
844: <span class="ruby-keyword kw">end</span>
|
967
|
+
845: <span class="ruby-identifier">joined_fragment</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">fragment</span>
|
968
|
+
846:
|
969
|
+
847: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
|
970
|
+
848: <span class="ruby-identifier">joined_scheme</span>,
|
971
|
+
849: <span class="ruby-identifier">joined_user</span>,
|
972
|
+
850: <span class="ruby-identifier">joined_password</span>,
|
973
|
+
851: <span class="ruby-identifier">joined_host</span>,
|
974
|
+
852: <span class="ruby-identifier">joined_port</span>,
|
975
|
+
853: <span class="ruby-identifier">joined_path</span>,
|
976
|
+
854: <span class="ruby-identifier">joined_query</span>,
|
977
|
+
855: <span class="ruby-identifier">joined_fragment</span>
|
978
|
+
856: )
|
979
|
+
857: <span class="ruby-keyword kw">end</span>
|
937
980
|
</pre>
|
938
981
|
</div>
|
939
982
|
</div>
|
940
983
|
</div>
|
941
984
|
|
942
|
-
<div id="method-
|
943
|
-
<a name="
|
985
|
+
<div id="method-M000052" class="method-detail">
|
986
|
+
<a name="M000052"></a>
|
944
987
|
|
945
988
|
<div class="method-heading">
|
946
|
-
<a href="#
|
989
|
+
<a href="#M000052" class="method-signature">
|
947
990
|
<span class="method-name">==</span><span class="method-args">(uri)</span>
|
948
991
|
</a>
|
949
992
|
</div>
|
@@ -954,24 +997,24 @@ Returns true if the <a href="URI.html">URI</a> objects are equal. This
|
|
954
997
|
method normalizes both URIs before doing the comparison.
|
955
998
|
</p>
|
956
999
|
<p><a class="source-toggle" href="#"
|
957
|
-
onclick="toggleCode('
|
958
|
-
<div class="method-source-code" id="
|
1000
|
+
onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
|
1001
|
+
<div class="method-source-code" id="M000052-source">
|
959
1002
|
<pre>
|
960
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
1003
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1043</span>
|
1004
|
+
1043: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">uri</span>)
|
1005
|
+
1044: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>)
|
1006
|
+
1045: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalize</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">normalize</span>.<span class="ruby-identifier">to_s</span>
|
1007
|
+
1046: <span class="ruby-keyword kw">end</span>
|
965
1008
|
</pre>
|
966
1009
|
</div>
|
967
1010
|
</div>
|
968
1011
|
</div>
|
969
1012
|
|
970
|
-
<div id="method-
|
971
|
-
<a name="
|
1013
|
+
<div id="method-M000051" class="method-detail">
|
1014
|
+
<a name="M000051"></a>
|
972
1015
|
|
973
1016
|
<div class="method-heading">
|
974
|
-
<a href="#
|
1017
|
+
<a href="#M000051" class="method-signature">
|
975
1018
|
<span class="method-name">===</span><span class="method-args">(uri)</span>
|
976
1019
|
</a>
|
977
1020
|
</div>
|
@@ -983,33 +1026,32 @@ method normalizes both URIs before doing the comparison, and allows
|
|
983
1026
|
comparison against strings.
|
984
1027
|
</p>
|
985
1028
|
<p><a class="source-toggle" href="#"
|
986
|
-
onclick="toggleCode('
|
987
|
-
<div class="method-source-code" id="
|
1029
|
+
onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
|
1030
|
+
<div class="method-source-code" id="M000051-source">
|
988
1031
|
<pre>
|
989
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
1019: <span class="ruby-keyword kw">end</span>
|
1032
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1028</span>
|
1033
|
+
1028: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">===</span>(<span class="ruby-identifier">uri</span>)
|
1034
|
+
1029: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:normalize</span>)
|
1035
|
+
1030: <span class="ruby-identifier">uri_string</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">normalize</span>.<span class="ruby-identifier">to_s</span>
|
1036
|
+
1031: <span class="ruby-keyword kw">else</span>
|
1037
|
+
1032: <span class="ruby-keyword kw">begin</span>
|
1038
|
+
1033: <span class="ruby-identifier">uri_string</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">normalize</span>.<span class="ruby-identifier">to_s</span>
|
1039
|
+
1034: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">InvalidURIError</span>
|
1040
|
+
1035: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
1041
|
+
1036: <span class="ruby-keyword kw">end</span>
|
1042
|
+
1037: <span class="ruby-keyword kw">end</span>
|
1043
|
+
1038: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalize</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri_string</span>
|
1044
|
+
1039: <span class="ruby-keyword kw">end</span>
|
1003
1045
|
</pre>
|
1004
1046
|
</div>
|
1005
1047
|
</div>
|
1006
1048
|
</div>
|
1007
1049
|
|
1008
|
-
<div id="method-
|
1009
|
-
<a name="
|
1050
|
+
<div id="method-M000040" class="method-detail">
|
1051
|
+
<a name="M000040"></a>
|
1010
1052
|
|
1011
1053
|
<div class="method-heading">
|
1012
|
-
<a href="#
|
1054
|
+
<a href="#M000040" class="method-signature">
|
1013
1055
|
<span class="method-name">absolute?</span><span class="method-args">()</span>
|
1014
1056
|
</a>
|
1015
1057
|
</div>
|
@@ -1019,140 +1061,139 @@ comparison against strings.
|
|
1019
1061
|
Returns true if this <a href="URI.html">URI</a> is known to be absolute.
|
1020
1062
|
</p>
|
1021
1063
|
<p><a class="source-toggle" href="#"
|
1022
|
-
onclick="toggleCode('
|
1023
|
-
<div class="method-source-code" id="
|
1064
|
+
onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
|
1065
|
+
<div class="method-source-code" id="M000040-source">
|
1024
1066
|
<pre>
|
1025
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1067
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 764</span>
|
1068
|
+
764: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">absolute?</span>
|
1069
|
+
765: <span class="ruby-keyword kw">return</span> <span class="ruby-operator">!</span><span class="ruby-identifier">relative?</span>
|
1070
|
+
766: <span class="ruby-keyword kw">end</span>
|
1029
1071
|
</pre>
|
1030
1072
|
</div>
|
1031
1073
|
</div>
|
1032
1074
|
</div>
|
1033
1075
|
|
1034
|
-
<div id="method-
|
1035
|
-
<a name="
|
1076
|
+
<div id="method-M000023" class="method-detail">
|
1077
|
+
<a name="M000023"></a>
|
1036
1078
|
|
1037
1079
|
<div class="method-heading">
|
1038
|
-
<a href="#
|
1080
|
+
<a href="#M000023" class="method-signature">
|
1039
1081
|
<span class="method-name">authority</span><span class="method-args">()</span>
|
1040
1082
|
</a>
|
1041
1083
|
</div>
|
1042
1084
|
|
1043
1085
|
<div class="method-description">
|
1044
1086
|
<p>
|
1045
|
-
Returns the <a href="URI.html#
|
1087
|
+
Returns the <a href="URI.html#M000023">authority</a> segment of this <a
|
1046
1088
|
href="URI.html">URI</a>.
|
1047
1089
|
</p>
|
1048
1090
|
<p><a class="source-toggle" href="#"
|
1049
|
-
onclick="toggleCode('
|
1050
|
-
<div class="method-source-code" id="
|
1091
|
+
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
1092
|
+
<div class="method-source-code" id="M000023-source">
|
1051
1093
|
<pre>
|
1052
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1094
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 598</span>
|
1095
|
+
598: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">authority</span>
|
1096
|
+
599: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">defined?</span>(<span class="ruby-ivar">@authority</span>) <span class="ruby-operator">||</span> <span class="ruby-ivar">@authority</span>.<span class="ruby-identifier">nil?</span>
|
1097
|
+
600: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>.<span class="ruby-identifier">nil?</span>
|
1098
|
+
601: <span class="ruby-ivar">@authority</span> = <span class="ruby-value str">""</span>
|
1099
|
+
602: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">userinfo</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1100
|
+
603: <span class="ruby-ivar">@authority</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{self.userinfo}@"</span>
|
1101
|
+
604: <span class="ruby-keyword kw">end</span>
|
1102
|
+
605: <span class="ruby-ivar">@authority</span> <span class="ruby-operator"><<</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>
|
1103
|
+
606: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">specified_port</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1104
|
+
607: <span class="ruby-ivar">@authority</span> <span class="ruby-operator"><<</span> <span class="ruby-node">":#{self.specified_port}"</span>
|
1105
|
+
608: <span class="ruby-keyword kw">end</span>
|
1106
|
+
609: <span class="ruby-keyword kw">end</span>
|
1107
|
+
610: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@authority</span>
|
1108
|
+
611: <span class="ruby-keyword kw">end</span>
|
1067
1109
|
</pre>
|
1068
1110
|
</div>
|
1069
1111
|
</div>
|
1070
1112
|
</div>
|
1071
1113
|
|
1072
|
-
<div id="method-
|
1073
|
-
<a name="
|
1114
|
+
<div id="method-M000024" class="method-detail">
|
1115
|
+
<a name="M000024"></a>
|
1074
1116
|
|
1075
1117
|
<div class="method-heading">
|
1076
|
-
<a href="#
|
1118
|
+
<a href="#M000024" class="method-signature">
|
1077
1119
|
<span class="method-name">authority=</span><span class="method-args">(new_authority)</span>
|
1078
1120
|
</a>
|
1079
1121
|
</div>
|
1080
1122
|
|
1081
1123
|
<div class="method-description">
|
1082
1124
|
<p>
|
1083
|
-
Sets the <a href="URI.html#
|
1125
|
+
Sets the <a href="URI.html#M000023">authority</a> segment of this <a
|
1084
1126
|
href="URI.html">URI</a>.
|
1085
1127
|
</p>
|
1086
1128
|
<p><a class="source-toggle" href="#"
|
1087
|
-
onclick="toggleCode('
|
1088
|
-
<div class="method-source-code" id="
|
1129
|
+
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
1130
|
+
<div class="method-source-code" id="M000024-source">
|
1089
1131
|
<pre>
|
1090
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
620: <span class="ruby-keyword kw">end</span>
|
1132
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 614</span>
|
1133
|
+
614: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">authority=</span>(<span class="ruby-identifier">new_authority</span>)
|
1134
|
+
615: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">new_authority</span>
|
1135
|
+
616: <span class="ruby-identifier">new_userinfo</span> = <span class="ruby-identifier">new_authority</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^([^\[\]]*)@/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
|
1136
|
+
617: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">new_userinfo</span>
|
1137
|
+
618: <span class="ruby-identifier">new_user</span> = <span class="ruby-identifier">new_userinfo</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^([^:]*):?/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
|
1138
|
+
619: <span class="ruby-identifier">new_password</span> = <span class="ruby-identifier">new_userinfo</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/:(.*)$/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
|
1139
|
+
620: <span class="ruby-keyword kw">end</span>
|
1140
|
+
621: <span class="ruby-identifier">new_host</span> =
|
1141
|
+
622: <span class="ruby-identifier">new_authority</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/^([^\[\]]*)@/</span>, <span class="ruby-value str">""</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/:([^:@\[\]]*?)$/</span>, <span class="ruby-value str">""</span>)
|
1142
|
+
623: <span class="ruby-identifier">new_port</span> =
|
1143
|
+
624: <span class="ruby-identifier">new_authority</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/:([^:@\[\]]*?)$/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
|
1144
|
+
625: <span class="ruby-keyword kw">end</span>
|
1145
|
+
626:
|
1146
|
+
627: <span class="ruby-comment cmt"># Password assigned first to ensure validity in case of nil</span>
|
1147
|
+
628: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span> = <span class="ruby-identifier">new_password</span>
|
1148
|
+
629: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span> = <span class="ruby-identifier">new_user</span>
|
1149
|
+
630: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span> = <span class="ruby-identifier">new_host</span>
|
1150
|
+
631:
|
1151
|
+
632: <span class="ruby-comment cmt"># Port reset to allow port normalization</span>
|
1152
|
+
633: <span class="ruby-ivar">@port</span> = <span class="ruby-keyword kw">nil</span>
|
1153
|
+
634: <span class="ruby-ivar">@specified_port</span> = <span class="ruby-identifier">new_port</span>
|
1154
|
+
635:
|
1155
|
+
636: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
|
1156
|
+
637: <span class="ruby-identifier">validate</span>()
|
1157
|
+
638: <span class="ruby-keyword kw">end</span>
|
1117
1158
|
</pre>
|
1118
1159
|
</div>
|
1119
1160
|
</div>
|
1120
1161
|
</div>
|
1121
1162
|
|
1122
|
-
<div id="method-
|
1123
|
-
<a name="
|
1163
|
+
<div id="method-M000032" class="method-detail">
|
1164
|
+
<a name="M000032"></a>
|
1124
1165
|
|
1125
1166
|
<div class="method-heading">
|
1126
|
-
<a href="#
|
1167
|
+
<a href="#M000032" class="method-signature">
|
1127
1168
|
<span class="method-name">basename</span><span class="method-args">()</span>
|
1128
1169
|
</a>
|
1129
1170
|
</div>
|
1130
1171
|
|
1131
1172
|
<div class="method-description">
|
1132
1173
|
<p>
|
1133
|
-
Returns the <a href="URI.html#
|
1134
|
-
the <a href="URI.html#
|
1135
|
-
there is no <a href="URI.html#
|
1174
|
+
Returns the <a href="URI.html#M000032">basename</a>, if any, of the file at
|
1175
|
+
the <a href="URI.html#M000030">path</a> being referenced. Returns nil if
|
1176
|
+
there is no <a href="URI.html#M000030">path</a> component.
|
1136
1177
|
</p>
|
1137
1178
|
<p><a class="source-toggle" href="#"
|
1138
|
-
onclick="toggleCode('
|
1139
|
-
<div class="method-source-code" id="
|
1179
|
+
onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
|
1180
|
+
<div class="method-source-code" id="M000032-source">
|
1140
1181
|
<pre>
|
1141
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1182
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 716</span>
|
1183
|
+
716: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">basename</span>
|
1184
|
+
717: <span class="ruby-comment cmt"># Path cannot be nil</span>
|
1185
|
+
718: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/;[^\/]*$/</span>, <span class="ruby-value str">""</span>)
|
1186
|
+
719: <span class="ruby-keyword kw">end</span>
|
1146
1187
|
</pre>
|
1147
1188
|
</div>
|
1148
1189
|
</div>
|
1149
1190
|
</div>
|
1150
1191
|
|
1151
|
-
<div id="method-
|
1152
|
-
<a name="
|
1192
|
+
<div id="method-M000050" class="method-detail">
|
1193
|
+
<a name="M000050"></a>
|
1153
1194
|
|
1154
1195
|
<div class="method-heading">
|
1155
|
-
<a href="#
|
1196
|
+
<a href="#M000050" class="method-signature">
|
1156
1197
|
<span class="method-name">display_uri</span><span class="method-args">()</span>
|
1157
1198
|
</a>
|
1158
1199
|
</div>
|
@@ -1161,34 +1202,34 @@ there is no <a href="URI.html#M000029">path</a> component.
|
|
1161
1202
|
<p>
|
1162
1203
|
Creates a <a href="URI.html">URI</a> suitable for display to users. If
|
1163
1204
|
semantic attacks are likely, the application should try to detect these and
|
1164
|
-
warn the <a href="URI.html#
|
1205
|
+
warn the <a href="URI.html#M000015">user</a>. See RFC 3986 section 7.6 for
|
1165
1206
|
more information.
|
1166
1207
|
</p>
|
1167
1208
|
<p><a class="source-toggle" href="#"
|
1168
|
-
onclick="toggleCode('
|
1169
|
-
<div class="method-source-code" id="
|
1209
|
+
onclick="toggleCode('M000050-source');return false;">[Source]</a></p>
|
1210
|
+
<div class="method-source-code" id="M000050-source">
|
1170
1211
|
<pre>
|
1171
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1212
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1014</span>
|
1213
|
+
1014: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">display_uri</span>
|
1214
|
+
1015: <span class="ruby-identifier">display_uri</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalize</span>
|
1215
|
+
1016: <span class="ruby-keyword kw">begin</span>
|
1216
|
+
1017: <span class="ruby-identifier">display_uri</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-value str">"@host"</span>,
|
1217
|
+
1018: <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">IDNA</span>.<span class="ruby-identifier">to_unicode</span>(<span class="ruby-identifier">display_uri</span>.<span class="ruby-identifier">host</span>))
|
1218
|
+
1019: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
|
1219
|
+
1020: <span class="ruby-keyword kw">nil</span>
|
1220
|
+
1021: <span class="ruby-keyword kw">end</span>
|
1221
|
+
1022: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">display_uri</span>
|
1222
|
+
1023: <span class="ruby-keyword kw">end</span>
|
1182
1223
|
</pre>
|
1183
1224
|
</div>
|
1184
1225
|
</div>
|
1185
1226
|
</div>
|
1186
1227
|
|
1187
|
-
<div id="method-
|
1188
|
-
<a name="
|
1228
|
+
<div id="method-M000054" class="method-detail">
|
1229
|
+
<a name="M000054"></a>
|
1189
1230
|
|
1190
1231
|
<div class="method-heading">
|
1191
|
-
<a href="#
|
1232
|
+
<a href="#M000054" class="method-signature">
|
1192
1233
|
<span class="method-name">dup</span><span class="method-args">()</span>
|
1193
1234
|
</a>
|
1194
1235
|
</div>
|
@@ -1198,50 +1239,41 @@ more information.
|
|
1198
1239
|
Clones the <a href="URI.html">URI</a> object.
|
1199
1240
|
</p>
|
1200
1241
|
<p><a class="source-toggle" href="#"
|
1201
|
-
onclick="toggleCode('
|
1202
|
-
<div class="method-source-code" id="
|
1242
|
+
onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
|
1243
|
+
<div class="method-source-code" id="M000054-source">
|
1203
1244
|
<pre>
|
1204
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
1057: <span class="ruby-identifier">duplicated_port</span>,
|
1227
|
-
1058: <span class="ruby-identifier">duplicated_path</span>,
|
1228
|
-
1059: <span class="ruby-identifier">duplicated_query</span>,
|
1229
|
-
1060: <span class="ruby-identifier">duplicated_fragment</span>
|
1230
|
-
1061: )
|
1231
|
-
1062: <span class="ruby-ivar">@specified_port</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">defined?</span>(<span class="ruby-ivar">@specified_port</span>)
|
1232
|
-
1063: <span class="ruby-identifier">duplicated_uri</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-value str">"@specified_port"</span>, <span class="ruby-ivar">@specified_port</span>)
|
1233
|
-
1064: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">duplicated_uri</span>
|
1234
|
-
1065: <span class="ruby-keyword kw">end</span>
|
1245
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1056</span>
|
1246
|
+
1056: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dup</span>
|
1247
|
+
1057: <span class="ruby-identifier">duplicated_scheme</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">dup</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
|
1248
|
+
1058: <span class="ruby-identifier">duplicated_user</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">dup</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
|
1249
|
+
1059: <span class="ruby-identifier">duplicated_password</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>.<span class="ruby-identifier">dup</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
|
1250
|
+
1060: <span class="ruby-identifier">duplicated_host</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>.<span class="ruby-identifier">dup</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
|
1251
|
+
1061: <span class="ruby-identifier">duplicated_port</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">specified_port</span>
|
1252
|
+
1062: <span class="ruby-identifier">duplicated_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">dup</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
|
1253
|
+
1063: <span class="ruby-identifier">duplicated_query</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>.<span class="ruby-identifier">dup</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
|
1254
|
+
1064: <span class="ruby-identifier">duplicated_fragment</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fragment</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fragment</span>.<span class="ruby-identifier">dup</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
|
1255
|
+
1065: <span class="ruby-identifier">duplicated_uri</span> = <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
|
1256
|
+
1066: <span class="ruby-identifier">duplicated_scheme</span>,
|
1257
|
+
1067: <span class="ruby-identifier">duplicated_user</span>,
|
1258
|
+
1068: <span class="ruby-identifier">duplicated_password</span>,
|
1259
|
+
1069: <span class="ruby-identifier">duplicated_host</span>,
|
1260
|
+
1070: <span class="ruby-identifier">duplicated_port</span>,
|
1261
|
+
1071: <span class="ruby-identifier">duplicated_path</span>,
|
1262
|
+
1072: <span class="ruby-identifier">duplicated_query</span>,
|
1263
|
+
1073: <span class="ruby-identifier">duplicated_fragment</span>
|
1264
|
+
1074: )
|
1265
|
+
1075: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">duplicated_uri</span>
|
1266
|
+
1076: <span class="ruby-keyword kw">end</span>
|
1235
1267
|
</pre>
|
1236
1268
|
</div>
|
1237
1269
|
</div>
|
1238
1270
|
</div>
|
1239
1271
|
|
1240
|
-
<div id="method-
|
1241
|
-
<a name="
|
1272
|
+
<div id="method-M000053" class="method-detail">
|
1273
|
+
<a name="M000053"></a>
|
1242
1274
|
|
1243
1275
|
<div class="method-heading">
|
1244
|
-
<a href="#
|
1276
|
+
<a href="#M000053" class="method-signature">
|
1245
1277
|
<span class="method-name">eql?</span><span class="method-args">(uri)</span>
|
1246
1278
|
</a>
|
1247
1279
|
</div>
|
@@ -1249,28 +1281,28 @@ Clones the <a href="URI.html">URI</a> object.
|
|
1249
1281
|
<div class="method-description">
|
1250
1282
|
<p>
|
1251
1283
|
Returns true if the <a href="URI.html">URI</a> objects are equal. This
|
1252
|
-
method does NOT <a href="URI.html#
|
1284
|
+
method does NOT <a href="URI.html#M000048">normalize</a> either <a
|
1253
1285
|
href="URI.html">URI</a> before doing the comparison.
|
1254
1286
|
</p>
|
1255
1287
|
<p><a class="source-toggle" href="#"
|
1256
|
-
onclick="toggleCode('
|
1257
|
-
<div class="method-source-code" id="
|
1288
|
+
onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
|
1289
|
+
<div class="method-source-code" id="M000053-source">
|
1258
1290
|
<pre>
|
1259
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1291
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1050</span>
|
1292
|
+
1050: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">eql?</span>(<span class="ruby-identifier">uri</span>)
|
1293
|
+
1051: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>)
|
1294
|
+
1052: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>
|
1295
|
+
1053: <span class="ruby-keyword kw">end</span>
|
1264
1296
|
</pre>
|
1265
1297
|
</div>
|
1266
1298
|
</div>
|
1267
1299
|
</div>
|
1268
1300
|
|
1269
|
-
<div id="method-
|
1270
|
-
<a name="
|
1301
|
+
<div id="method-M000033" class="method-detail">
|
1302
|
+
<a name="M000033"></a>
|
1271
1303
|
|
1272
1304
|
<div class="method-heading">
|
1273
|
-
<a href="#
|
1305
|
+
<a href="#M000033" class="method-signature">
|
1274
1306
|
<span class="method-name">extname</span><span class="method-args">()</span>
|
1275
1307
|
</a>
|
1276
1308
|
</div>
|
@@ -1278,29 +1310,29 @@ href="URI.html">URI</a> before doing the comparison.
|
|
1278
1310
|
<div class="method-description">
|
1279
1311
|
<p>
|
1280
1312
|
Returns the extension, if any, of the file at the <a
|
1281
|
-
href="URI.html#
|
1313
|
+
href="URI.html#M000030">path</a> being referenced. Returns "" if
|
1282
1314
|
there is no extension or nil if there is no <a
|
1283
|
-
href="URI.html#
|
1315
|
+
href="URI.html#M000030">path</a> component.
|
1284
1316
|
</p>
|
1285
1317
|
<p><a class="source-toggle" href="#"
|
1286
|
-
onclick="toggleCode('
|
1287
|
-
<div class="method-source-code" id="
|
1318
|
+
onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
|
1319
|
+
<div class="method-source-code" id="M000033-source">
|
1288
1320
|
<pre>
|
1289
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1321
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 724</span>
|
1322
|
+
724: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">extname</span>
|
1323
|
+
725: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>
|
1324
|
+
726: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">basename</span>)
|
1325
|
+
727: <span class="ruby-keyword kw">end</span>
|
1294
1326
|
</pre>
|
1295
1327
|
</div>
|
1296
1328
|
</div>
|
1297
1329
|
</div>
|
1298
1330
|
|
1299
|
-
<div id="method-
|
1300
|
-
<a name="
|
1331
|
+
<div id="method-M000005" class="method-detail">
|
1332
|
+
<a name="M000005"></a>
|
1301
1333
|
|
1302
1334
|
<div class="method-heading">
|
1303
|
-
<a href="#
|
1335
|
+
<a href="#M000005" class="method-signature">
|
1304
1336
|
<span class="method-name">extract_mapping</span><span class="method-args">(pattern, processor=nil)</span>
|
1305
1337
|
</a>
|
1306
1338
|
</div>
|
@@ -1350,174 +1382,174 @@ An example:
|
|
1350
1382
|
=> {"first" => "a", "second" => "b/c"}
|
1351
1383
|
</pre>
|
1352
1384
|
<p><a class="source-toggle" href="#"
|
1353
|
-
onclick="toggleCode('
|
1354
|
-
<div class="method-source-code" id="
|
1385
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
1386
|
+
<div class="method-source-code" id="M000005-source">
|
1355
1387
|
<pre>
|
1356
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1388
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 267</span>
|
1389
|
+
267: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">extract_mapping</span>(<span class="ruby-identifier">pattern</span>, <span class="ruby-identifier">processor</span>=<span class="ruby-keyword kw">nil</span>)
|
1390
|
+
268: <span class="ruby-identifier">mapping</span> = {}
|
1391
|
+
269: <span class="ruby-identifier">variable_regexp</span> =
|
1392
|
+
270: <span class="ruby-node">/\{([#{Addressable::URI::CharacterClasses::UNRESERVED}]+)\}/</span>
|
1393
|
+
271: <span class="ruby-identifier">variables</span> = <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">variable_regexp</span>).<span class="ruby-identifier">flatten</span>
|
1394
|
+
272: <span class="ruby-identifier">variables</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">mapping</span>[<span class="ruby-identifier">v</span>] = <span class="ruby-value str">""</span> }
|
1395
|
+
273: <span class="ruby-identifier">escaped_pattern</span> =
|
1396
|
+
274: <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">pattern</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\\\{/</span>, <span class="ruby-value str">"{"</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\\\}/</span>, <span class="ruby-value str">"}"</span>)
|
1397
|
+
275: <span class="ruby-identifier">regexp</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">escaped_pattern</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">variable_regexp</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
1398
|
+
276: <span class="ruby-identifier">capture_group</span> = <span class="ruby-value str">"(.*)"</span>
|
1399
|
+
277:
|
1400
|
+
278: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">processor</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1401
|
+
279: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">processor</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:match</span>)
|
1402
|
+
280: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">v</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">variable_regexp</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
|
1403
|
+
281: <span class="ruby-identifier">capture_group</span> = <span class="ruby-node">"(#{processor.match(name)})"</span>
|
1404
|
+
282: <span class="ruby-keyword kw">end</span>
|
1405
|
+
283: <span class="ruby-keyword kw">end</span>
|
1406
|
+
284:
|
1407
|
+
285: <span class="ruby-identifier">capture_group</span>
|
1408
|
+
286: <span class="ruby-keyword kw">end</span>)
|
1409
|
+
287: <span class="ruby-identifier">values</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">regexp</span>).<span class="ruby-identifier">flatten</span>
|
1410
|
+
288: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">variables</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">values</span>.<span class="ruby-identifier">size</span>
|
1411
|
+
289: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword kw">in</span> <span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-identifier">variables</span>.<span class="ruby-identifier">size</span>
|
1412
|
+
290: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">variables</span>[<span class="ruby-identifier">i</span>]
|
1413
|
+
291: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">values</span>[<span class="ruby-identifier">i</span>]
|
1414
|
+
292:
|
1415
|
+
293: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">processor</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1416
|
+
294: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">processor</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:restore</span>)
|
1417
|
+
295: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">processor</span>.<span class="ruby-identifier">restore</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
|
1418
|
+
296: <span class="ruby-keyword kw">end</span>
|
1419
|
+
297: <span class="ruby-keyword kw">end</span>
|
1420
|
+
298:
|
1421
|
+
299: <span class="ruby-identifier">mapping</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">value</span>
|
1422
|
+
300: <span class="ruby-keyword kw">end</span>
|
1423
|
+
301: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">mapping</span>
|
1424
|
+
302: <span class="ruby-keyword kw">else</span>
|
1425
|
+
303: <span class="ruby-comment cmt"># Pattern failed to match URI.</span>
|
1426
|
+
304: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
|
1427
|
+
305: <span class="ruby-keyword kw">end</span>
|
1428
|
+
306: <span class="ruby-keyword kw">end</span>
|
1397
1429
|
</pre>
|
1398
1430
|
</div>
|
1399
1431
|
</div>
|
1400
1432
|
</div>
|
1401
1433
|
|
1402
|
-
<div id="method-
|
1403
|
-
<a name="
|
1434
|
+
<div id="method-M000036" class="method-detail">
|
1435
|
+
<a name="M000036"></a>
|
1404
1436
|
|
1405
1437
|
<div class="method-heading">
|
1406
|
-
<a href="#
|
1438
|
+
<a href="#M000036" class="method-signature">
|
1407
1439
|
<span class="method-name">fragment</span><span class="method-args">()</span>
|
1408
1440
|
</a>
|
1409
1441
|
</div>
|
1410
1442
|
|
1411
1443
|
<div class="method-description">
|
1412
1444
|
<p>
|
1413
|
-
Returns the <a href="URI.html#
|
1445
|
+
Returns the <a href="URI.html#M000036">fragment</a> for this <a
|
1414
1446
|
href="URI.html">URI</a>.
|
1415
1447
|
</p>
|
1416
1448
|
<p><a class="source-toggle" href="#"
|
1417
|
-
onclick="toggleCode('
|
1418
|
-
<div class="method-source-code" id="
|
1449
|
+
onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
|
1450
|
+
<div class="method-source-code" id="M000036-source">
|
1419
1451
|
<pre>
|
1420
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1452
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 740</span>
|
1453
|
+
740: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fragment</span>
|
1454
|
+
741: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@fragment</span>
|
1455
|
+
742: <span class="ruby-keyword kw">end</span>
|
1424
1456
|
</pre>
|
1425
1457
|
</div>
|
1426
1458
|
</div>
|
1427
1459
|
</div>
|
1428
1460
|
|
1429
|
-
<div id="method-
|
1430
|
-
<a name="
|
1461
|
+
<div id="method-M000037" class="method-detail">
|
1462
|
+
<a name="M000037"></a>
|
1431
1463
|
|
1432
1464
|
<div class="method-heading">
|
1433
|
-
<a href="#
|
1465
|
+
<a href="#M000037" class="method-signature">
|
1434
1466
|
<span class="method-name">fragment=</span><span class="method-args">(new_fragment)</span>
|
1435
1467
|
</a>
|
1436
1468
|
</div>
|
1437
1469
|
|
1438
1470
|
<div class="method-description">
|
1439
1471
|
<p>
|
1440
|
-
Sets the <a href="URI.html#
|
1472
|
+
Sets the <a href="URI.html#M000036">fragment</a> for this <a
|
1441
1473
|
href="URI.html">URI</a>.
|
1442
1474
|
</p>
|
1443
1475
|
<p><a class="source-toggle" href="#"
|
1444
|
-
onclick="toggleCode('
|
1445
|
-
<div class="method-source-code" id="
|
1476
|
+
onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
|
1477
|
+
<div class="method-source-code" id="M000037-source">
|
1446
1478
|
<pre>
|
1447
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1479
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 745</span>
|
1480
|
+
745: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fragment=</span>(<span class="ruby-identifier">new_fragment</span>)
|
1481
|
+
746: <span class="ruby-ivar">@fragment</span> = <span class="ruby-identifier">new_fragment</span>
|
1482
|
+
747: <span class="ruby-keyword kw">end</span>
|
1451
1483
|
</pre>
|
1452
1484
|
</div>
|
1453
1485
|
</div>
|
1454
1486
|
</div>
|
1455
1487
|
|
1456
|
-
<div id="method-
|
1457
|
-
<a name="
|
1488
|
+
<div id="method-M000021" class="method-detail">
|
1489
|
+
<a name="M000021"></a>
|
1458
1490
|
|
1459
1491
|
<div class="method-heading">
|
1460
|
-
<a href="#
|
1492
|
+
<a href="#M000021" class="method-signature">
|
1461
1493
|
<span class="method-name">host</span><span class="method-args">()</span>
|
1462
1494
|
</a>
|
1463
1495
|
</div>
|
1464
1496
|
|
1465
1497
|
<div class="method-description">
|
1466
1498
|
<p>
|
1467
|
-
Returns the <a href="URI.html#
|
1499
|
+
Returns the <a href="URI.html#M000021">host</a> for this <a
|
1468
1500
|
href="URI.html">URI</a>.
|
1469
1501
|
</p>
|
1470
1502
|
<p><a class="source-toggle" href="#"
|
1471
|
-
onclick="toggleCode('
|
1472
|
-
<div class="method-source-code" id="
|
1503
|
+
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
1504
|
+
<div class="method-source-code" id="M000021-source">
|
1473
1505
|
<pre>
|
1474
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1506
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 582</span>
|
1507
|
+
582: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">host</span>
|
1508
|
+
583: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@host</span>
|
1509
|
+
584: <span class="ruby-keyword kw">end</span>
|
1478
1510
|
</pre>
|
1479
1511
|
</div>
|
1480
1512
|
</div>
|
1481
1513
|
</div>
|
1482
1514
|
|
1483
|
-
<div id="method-
|
1484
|
-
<a name="
|
1515
|
+
<div id="method-M000022" class="method-detail">
|
1516
|
+
<a name="M000022"></a>
|
1485
1517
|
|
1486
1518
|
<div class="method-heading">
|
1487
|
-
<a href="#
|
1519
|
+
<a href="#M000022" class="method-signature">
|
1488
1520
|
<span class="method-name">host=</span><span class="method-args">(new_host)</span>
|
1489
1521
|
</a>
|
1490
1522
|
</div>
|
1491
1523
|
|
1492
1524
|
<div class="method-description">
|
1493
1525
|
<p>
|
1494
|
-
Sets the <a href="URI.html#
|
1526
|
+
Sets the <a href="URI.html#M000021">host</a> for this <a
|
1495
1527
|
href="URI.html">URI</a>.
|
1496
1528
|
</p>
|
1497
1529
|
<p><a class="source-toggle" href="#"
|
1498
|
-
onclick="toggleCode('
|
1499
|
-
<div class="method-source-code" id="
|
1530
|
+
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
1531
|
+
<div class="method-source-code" id="M000022-source">
|
1500
1532
|
<pre>
|
1501
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1533
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 587</span>
|
1534
|
+
587: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">host=</span>(<span class="ruby-identifier">new_host</span>)
|
1535
|
+
588: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">new_host</span>
|
1536
|
+
589:
|
1537
|
+
590: <span class="ruby-comment cmt"># Reset dependant values</span>
|
1538
|
+
591: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
|
1539
|
+
592:
|
1540
|
+
593: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
|
1541
|
+
594: <span class="ruby-identifier">validate</span>()
|
1542
|
+
595: <span class="ruby-keyword kw">end</span>
|
1511
1543
|
</pre>
|
1512
1544
|
</div>
|
1513
1545
|
</div>
|
1514
1546
|
</div>
|
1515
1547
|
|
1516
|
-
<div id="method-
|
1517
|
-
<a name="
|
1548
|
+
<div id="method-M000057" class="method-detail">
|
1549
|
+
<a name="M000057"></a>
|
1518
1550
|
|
1519
1551
|
<div class="method-heading">
|
1520
|
-
<a href="#
|
1552
|
+
<a href="#M000057" class="method-signature">
|
1521
1553
|
<span class="method-name">inspect</span><span class="method-args">()</span>
|
1522
1554
|
</a>
|
1523
1555
|
</div>
|
@@ -1528,23 +1560,23 @@ Returns a string representation of the <a href="URI.html">URI</a>
|
|
1528
1560
|
object‘s state.
|
1529
1561
|
</p>
|
1530
1562
|
<p><a class="source-toggle" href="#"
|
1531
|
-
onclick="toggleCode('
|
1532
|
-
<div class="method-source-code" id="
|
1563
|
+
onclick="toggleCode('M000057-source');return false;">[Source]</a></p>
|
1564
|
+
<div class="method-source-code" id="M000057-source">
|
1533
1565
|
<pre>
|
1534
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1566
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1104</span>
|
1567
|
+
1104: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inspect</span>
|
1568
|
+
1105: <span class="ruby-identifier">sprintf</span>(<span class="ruby-value str">"#<%s:%#0x URI:%s>"</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">object_id</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>)
|
1569
|
+
1106: <span class="ruby-keyword kw">end</span>
|
1538
1570
|
</pre>
|
1539
1571
|
</div>
|
1540
1572
|
</div>
|
1541
1573
|
</div>
|
1542
1574
|
|
1543
|
-
<div id="method-
|
1544
|
-
<a name="
|
1575
|
+
<div id="method-M000038" class="method-detail">
|
1576
|
+
<a name="M000038"></a>
|
1545
1577
|
|
1546
1578
|
<div class="method-heading">
|
1547
|
-
<a href="#
|
1579
|
+
<a href="#M000038" class="method-signature">
|
1548
1580
|
<span class="method-name">ip_based?</span><span class="method-args">()</span>
|
1549
1581
|
</a>
|
1550
1582
|
</div>
|
@@ -1554,21 +1586,24 @@ object‘s state.
|
|
1554
1586
|
Returns true if the <a href="URI.html">URI</a> uses an IP-based protocol.
|
1555
1587
|
</p>
|
1556
1588
|
<p><a class="source-toggle" href="#"
|
1557
|
-
onclick="toggleCode('
|
1558
|
-
<div class="method-source-code" id="
|
1589
|
+
onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
|
1590
|
+
<div class="method-source-code" id="M000038-source">
|
1559
1591
|
<pre>
|
1560
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1592
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 750</span>
|
1593
|
+
750: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ip_based?</span>
|
1594
|
+
751: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>
|
1595
|
+
752: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">ip_based_schemes</span>.<span class="ruby-identifier">include?</span>(
|
1596
|
+
753: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">downcase</span>)
|
1597
|
+
754: <span class="ruby-keyword kw">end</span>
|
1598
|
+
755: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
1599
|
+
756: <span class="ruby-keyword kw">end</span>
|
1565
1600
|
</pre>
|
1566
1601
|
</div>
|
1567
1602
|
</div>
|
1568
1603
|
</div>
|
1569
1604
|
|
1570
|
-
<div id="method-
|
1571
|
-
<a name="
|
1605
|
+
<div id="method-M000043" class="method-detail">
|
1606
|
+
<a name="M000043"></a>
|
1572
1607
|
|
1573
1608
|
<div class="method-heading">
|
1574
1609
|
<span class="method-name">join</span><span class="method-args">(uri)</span>
|
@@ -1576,13 +1611,13 @@ Returns true if the <a href="URI.html">URI</a> uses an IP-based protocol.
|
|
1576
1611
|
|
1577
1612
|
<div class="method-description">
|
1578
1613
|
<p>
|
1579
|
-
Alias for <a href="URI.html#
|
1614
|
+
Alias for <a href="URI.html#M000042">merge</a>
|
1580
1615
|
</p>
|
1581
1616
|
</div>
|
1582
1617
|
</div>
|
1583
1618
|
|
1584
|
-
<div id="method-
|
1585
|
-
<a name="
|
1619
|
+
<div id="method-M000045" class="method-detail">
|
1620
|
+
<a name="M000045"></a>
|
1586
1621
|
|
1587
1622
|
<div class="method-heading">
|
1588
1623
|
<span class="method-name">join!</span><span class="method-args">(uri)</span>
|
@@ -1590,16 +1625,16 @@ Alias for <a href="URI.html#M000041">merge</a>
|
|
1590
1625
|
|
1591
1626
|
<div class="method-description">
|
1592
1627
|
<p>
|
1593
|
-
Alias for <a href="URI.html#
|
1628
|
+
Alias for <a href="URI.html#M000042">merge</a>!
|
1594
1629
|
</p>
|
1595
1630
|
</div>
|
1596
1631
|
</div>
|
1597
1632
|
|
1598
|
-
<div id="method-
|
1599
|
-
<a name="
|
1633
|
+
<div id="method-M000042" class="method-detail">
|
1634
|
+
<a name="M000042"></a>
|
1600
1635
|
|
1601
1636
|
<div class="method-heading">
|
1602
|
-
<a href="#
|
1637
|
+
<a href="#M000042" class="method-signature">
|
1603
1638
|
<span class="method-name">merge</span><span class="method-args">(uri)</span>
|
1604
1639
|
</a>
|
1605
1640
|
</div>
|
@@ -1609,49 +1644,49 @@ Alias for <a href="URI.html#M000041">merge</a>!
|
|
1609
1644
|
Merges two URIs together.
|
1610
1645
|
</p>
|
1611
1646
|
<p><a class="source-toggle" href="#"
|
1612
|
-
onclick="toggleCode('
|
1613
|
-
<div class="method-source-code" id="
|
1647
|
+
onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
|
1648
|
+
<div class="method-source-code" id="M000042-source">
|
1614
1649
|
<pre>
|
1615
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1650
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 860</span>
|
1651
|
+
860: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">uri</span>)
|
1652
|
+
861: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">uri</span>
|
1653
|
+
862: <span class="ruby-keyword kw">end</span>
|
1619
1654
|
</pre>
|
1620
1655
|
</div>
|
1621
1656
|
</div>
|
1622
1657
|
</div>
|
1623
1658
|
|
1624
|
-
<div id="method-
|
1625
|
-
<a name="
|
1659
|
+
<div id="method-M000044" class="method-detail">
|
1660
|
+
<a name="M000044"></a>
|
1626
1661
|
|
1627
1662
|
<div class="method-heading">
|
1628
|
-
<a href="#
|
1663
|
+
<a href="#M000044" class="method-signature">
|
1629
1664
|
<span class="method-name">merge!</span><span class="method-args">(uri)</span>
|
1630
1665
|
</a>
|
1631
1666
|
</div>
|
1632
1667
|
|
1633
1668
|
<div class="method-description">
|
1634
1669
|
<p>
|
1635
|
-
Destructive form of <a href="URI.html#
|
1670
|
+
Destructive form of <a href="URI.html#M000042">merge</a>.
|
1636
1671
|
</p>
|
1637
1672
|
<p><a class="source-toggle" href="#"
|
1638
|
-
onclick="toggleCode('
|
1639
|
-
<div class="method-source-code" id="
|
1673
|
+
onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
|
1674
|
+
<div class="method-source-code" id="M000044-source">
|
1640
1675
|
<pre>
|
1641
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1676
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 866</span>
|
1677
|
+
866: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">uri</span>)
|
1678
|
+
867: <span class="ruby-identifier">replace_self</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">uri</span>))
|
1679
|
+
868: <span class="ruby-keyword kw">end</span>
|
1645
1680
|
</pre>
|
1646
1681
|
</div>
|
1647
1682
|
</div>
|
1648
1683
|
</div>
|
1649
1684
|
|
1650
|
-
<div id="method-
|
1651
|
-
<a name="
|
1685
|
+
<div id="method-M000048" class="method-detail">
|
1686
|
+
<a name="M000048"></a>
|
1652
1687
|
|
1653
1688
|
<div class="method-heading">
|
1654
|
-
<a href="#
|
1689
|
+
<a href="#M000048" class="method-signature">
|
1655
1690
|
<span class="method-name">normalize</span><span class="method-args">()</span>
|
1656
1691
|
</a>
|
1657
1692
|
</div>
|
@@ -1668,91 +1703,88 @@ different URIs may represent the same resource and should not be cached
|
|
1668
1703
|
multiple times.
|
1669
1704
|
</p>
|
1670
1705
|
<p><a class="source-toggle" href="#"
|
1671
|
-
onclick="toggleCode('
|
1672
|
-
<div class="method-source-code" id="
|
1706
|
+
onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
|
1707
|
+
<div class="method-source-code" id="M000048-source">
|
1673
1708
|
<pre>
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
981: <span class="ruby-identifier">normalized_fragment</span>
|
1744
|
-
982: )))
|
1745
|
-
983: <span class="ruby-keyword kw">end</span>
|
1709
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 937</span>
|
1710
|
+
937: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">normalize</span>
|
1711
|
+
938: <span class="ruby-identifier">normalized_scheme</span> = <span class="ruby-keyword kw">nil</span>
|
1712
|
+
939: <span class="ruby-identifier">normalized_scheme</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">downcase</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1713
|
+
940: <span class="ruby-identifier">normalized_scheme</span> = <span class="ruby-value str">"svn+ssh"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"ssh+svn"</span>
|
1714
|
+
941: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_scheme</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"feed"</span>
|
1715
|
+
942: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^feed:\/*http:\/*/</span>
|
1716
|
+
943: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">parse</span>(
|
1717
|
+
944: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^feed:\/*(http:\/*.*)/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]).<span class="ruby-identifier">normalize</span>
|
1718
|
+
945: <span class="ruby-keyword kw">end</span>
|
1719
|
+
946: <span class="ruby-keyword kw">end</span>
|
1720
|
+
947: <span class="ruby-identifier">normalized_user</span> = <span class="ruby-keyword kw">nil</span>
|
1721
|
+
948: <span class="ruby-identifier">normalized_user</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1722
|
+
949: <span class="ruby-identifier">normalized_password</span> = <span class="ruby-keyword kw">nil</span>
|
1723
|
+
950: <span class="ruby-identifier">normalized_password</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1724
|
+
951:
|
1725
|
+
952: <span class="ruby-comment cmt"># If we are using http or https and user/password are blank,</span>
|
1726
|
+
953: <span class="ruby-comment cmt"># then we remove them</span>
|
1727
|
+
954: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_scheme</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/https?/</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">normalized_user</span> <span class="ruby-operator">==</span> <span class="ruby-value str">""</span> <span class="ruby-operator">&&</span>
|
1728
|
+
955: (<span class="ruby-operator">!</span><span class="ruby-identifier">normalized_password</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">normalized_password</span> <span class="ruby-operator">==</span> <span class="ruby-value str">""</span>)
|
1729
|
+
956: <span class="ruby-identifier">normalized_user</span> = <span class="ruby-keyword kw">nil</span>
|
1730
|
+
957: <span class="ruby-identifier">normalized_password</span> = <span class="ruby-keyword kw">nil</span>
|
1731
|
+
958: <span class="ruby-keyword kw">end</span>
|
1732
|
+
959:
|
1733
|
+
960: <span class="ruby-identifier">normalized_host</span> = <span class="ruby-keyword kw">nil</span>
|
1734
|
+
961: <span class="ruby-identifier">normalized_host</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">downcase</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1735
|
+
962: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_host</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1736
|
+
963: <span class="ruby-keyword kw">begin</span>
|
1737
|
+
964: <span class="ruby-identifier">normalized_host</span> = <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">IDNA</span>.<span class="ruby-identifier">to_ascii</span>(<span class="ruby-identifier">normalized_host</span>)
|
1738
|
+
965: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
|
1739
|
+
966: <span class="ruby-keyword kw">nil</span>
|
1740
|
+
967: <span class="ruby-keyword kw">end</span>
|
1741
|
+
968: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_host</span>[<span class="ruby-value">-1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"."</span>
|
1742
|
+
969: <span class="ruby-identifier">normalized_host</span> = <span class="ruby-identifier">normalized_host</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>]
|
1743
|
+
970: <span class="ruby-keyword kw">end</span>
|
1744
|
+
971: <span class="ruby-keyword kw">end</span>
|
1745
|
+
972:
|
1746
|
+
973: <span class="ruby-identifier">normalized_port</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">port</span>
|
1747
|
+
974: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">scheme_mapping</span>[<span class="ruby-identifier">normalized_scheme</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">normalized_port</span>
|
1748
|
+
975: <span class="ruby-identifier">normalized_port</span> = <span class="ruby-keyword kw">nil</span>
|
1749
|
+
976: <span class="ruby-keyword kw">end</span>
|
1750
|
+
977: <span class="ruby-identifier">normalized_path</span> = <span class="ruby-keyword kw">nil</span>
|
1751
|
+
978: <span class="ruby-identifier">normalized_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1752
|
+
979: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_path</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1753
|
+
980: <span class="ruby-identifier">normalized_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">normalized_path</span>)
|
1754
|
+
981: <span class="ruby-keyword kw">end</span>
|
1755
|
+
982: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_path</span> <span class="ruby-operator">==</span> <span class="ruby-value str">""</span>
|
1756
|
+
983: <span class="ruby-keyword kw">if</span> [<span class="ruby-value str">"http"</span>, <span class="ruby-value str">"https"</span>, <span class="ruby-value str">"ftp"</span>, <span class="ruby-value str">"tftp"</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">normalized_scheme</span>)
|
1757
|
+
984: <span class="ruby-identifier">normalized_path</span> = <span class="ruby-value str">"/"</span>
|
1758
|
+
985: <span class="ruby-keyword kw">end</span>
|
1759
|
+
986: <span class="ruby-keyword kw">end</span>
|
1760
|
+
987:
|
1761
|
+
988: <span class="ruby-identifier">normalized_query</span> = <span class="ruby-keyword kw">nil</span>
|
1762
|
+
989: <span class="ruby-identifier">normalized_query</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1763
|
+
990:
|
1764
|
+
991: <span class="ruby-identifier">normalized_fragment</span> = <span class="ruby-keyword kw">nil</span>
|
1765
|
+
992: <span class="ruby-identifier">normalized_fragment</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fragment</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fragment</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1766
|
+
993: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(
|
1767
|
+
994: <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">normalized_encode</span>(<span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
|
1768
|
+
995: <span class="ruby-identifier">normalized_scheme</span>,
|
1769
|
+
996: <span class="ruby-identifier">normalized_user</span>,
|
1770
|
+
997: <span class="ruby-identifier">normalized_password</span>,
|
1771
|
+
998: <span class="ruby-identifier">normalized_host</span>,
|
1772
|
+
999: <span class="ruby-identifier">normalized_port</span>,
|
1773
|
+
1000: <span class="ruby-identifier">normalized_path</span>,
|
1774
|
+
1001: <span class="ruby-identifier">normalized_query</span>,
|
1775
|
+
1002: <span class="ruby-identifier">normalized_fragment</span>
|
1776
|
+
1003: )))
|
1777
|
+
1004: <span class="ruby-keyword kw">end</span>
|
1746
1778
|
</pre>
|
1747
1779
|
</div>
|
1748
1780
|
</div>
|
1749
1781
|
</div>
|
1750
1782
|
|
1751
|
-
<div id="method-
|
1752
|
-
<a name="
|
1783
|
+
<div id="method-M000049" class="method-detail">
|
1784
|
+
<a name="M000049"></a>
|
1753
1785
|
|
1754
1786
|
<div class="method-heading">
|
1755
|
-
<a href="#
|
1787
|
+
<a href="#M000049" class="method-signature">
|
1756
1788
|
<span class="method-name">normalize!</span><span class="method-args">()</span>
|
1757
1789
|
</a>
|
1758
1790
|
</div>
|
@@ -1762,268 +1794,268 @@ multiple times.
|
|
1762
1794
|
Destructively normalizes this <a href="URI.html">URI</a> object.
|
1763
1795
|
</p>
|
1764
1796
|
<p><a class="source-toggle" href="#"
|
1765
|
-
onclick="toggleCode('
|
1766
|
-
<div class="method-source-code" id="
|
1797
|
+
onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
|
1798
|
+
<div class="method-source-code" id="M000049-source">
|
1767
1799
|
<pre>
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1800
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1007</span>
|
1801
|
+
1007: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">normalize!</span>
|
1802
|
+
1008: <span class="ruby-identifier">replace_self</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalize</span>)
|
1803
|
+
1009: <span class="ruby-keyword kw">end</span>
|
1772
1804
|
</pre>
|
1773
1805
|
</div>
|
1774
1806
|
</div>
|
1775
1807
|
</div>
|
1776
1808
|
|
1777
|
-
<div id="method-
|
1778
|
-
<a name="
|
1809
|
+
<div id="method-M000017" class="method-detail">
|
1810
|
+
<a name="M000017"></a>
|
1779
1811
|
|
1780
1812
|
<div class="method-heading">
|
1781
|
-
<a href="#
|
1813
|
+
<a href="#M000017" class="method-signature">
|
1782
1814
|
<span class="method-name">password</span><span class="method-args">()</span>
|
1783
1815
|
</a>
|
1784
1816
|
</div>
|
1785
1817
|
|
1786
1818
|
<div class="method-description">
|
1787
1819
|
<p>
|
1788
|
-
Returns the <a href="URI.html#
|
1820
|
+
Returns the <a href="URI.html#M000017">password</a> for this <a
|
1789
1821
|
href="URI.html">URI</a>.
|
1790
1822
|
</p>
|
1791
1823
|
<p><a class="source-toggle" href="#"
|
1792
|
-
onclick="toggleCode('
|
1793
|
-
<div class="method-source-code" id="
|
1824
|
+
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
1825
|
+
<div class="method-source-code" id="M000017-source">
|
1794
1826
|
<pre>
|
1795
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1827
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 528</span>
|
1828
|
+
528: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">password</span>
|
1829
|
+
529: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@password</span>
|
1830
|
+
530: <span class="ruby-keyword kw">end</span>
|
1799
1831
|
</pre>
|
1800
1832
|
</div>
|
1801
1833
|
</div>
|
1802
1834
|
</div>
|
1803
1835
|
|
1804
|
-
<div id="method-
|
1805
|
-
<a name="
|
1836
|
+
<div id="method-M000018" class="method-detail">
|
1837
|
+
<a name="M000018"></a>
|
1806
1838
|
|
1807
1839
|
<div class="method-heading">
|
1808
|
-
<a href="#
|
1840
|
+
<a href="#M000018" class="method-signature">
|
1809
1841
|
<span class="method-name">password=</span><span class="method-args">(new_password)</span>
|
1810
1842
|
</a>
|
1811
1843
|
</div>
|
1812
1844
|
|
1813
1845
|
<div class="method-description">
|
1814
1846
|
<p>
|
1815
|
-
Sets the <a href="URI.html#
|
1847
|
+
Sets the <a href="URI.html#M000017">password</a> for this <a
|
1816
1848
|
href="URI.html">URI</a>.
|
1817
1849
|
</p>
|
1818
1850
|
<p><a class="source-toggle" href="#"
|
1819
|
-
onclick="toggleCode('
|
1820
|
-
<div class="method-source-code" id="
|
1851
|
+
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
1852
|
+
<div class="method-source-code" id="M000018-source">
|
1821
1853
|
<pre>
|
1822
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1854
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 533</span>
|
1855
|
+
533: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">password=</span>(<span class="ruby-identifier">new_password</span>)
|
1856
|
+
534: <span class="ruby-ivar">@password</span> = <span class="ruby-identifier">new_password</span>
|
1857
|
+
535:
|
1858
|
+
536: <span class="ruby-comment cmt"># You can't have a nil user with a non-nil password</span>
|
1859
|
+
537: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@password</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
1860
|
+
538: <span class="ruby-ivar">@user</span> = <span class="ruby-value str">""</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@user</span>.<span class="ruby-identifier">nil?</span>
|
1861
|
+
539: <span class="ruby-keyword kw">end</span>
|
1862
|
+
540:
|
1863
|
+
541: <span class="ruby-comment cmt"># Reset dependant values</span>
|
1864
|
+
542: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-keyword kw">nil</span>
|
1865
|
+
543: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
|
1866
|
+
544:
|
1867
|
+
545: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
|
1868
|
+
546: <span class="ruby-identifier">validate</span>()
|
1869
|
+
547: <span class="ruby-keyword kw">end</span>
|
1838
1870
|
</pre>
|
1839
1871
|
</div>
|
1840
1872
|
</div>
|
1841
1873
|
</div>
|
1842
1874
|
|
1843
|
-
<div id="method-
|
1844
|
-
<a name="
|
1875
|
+
<div id="method-M000030" class="method-detail">
|
1876
|
+
<a name="M000030"></a>
|
1845
1877
|
|
1846
1878
|
<div class="method-heading">
|
1847
|
-
<a href="#
|
1879
|
+
<a href="#M000030" class="method-signature">
|
1848
1880
|
<span class="method-name">path</span><span class="method-args">()</span>
|
1849
1881
|
</a>
|
1850
1882
|
</div>
|
1851
1883
|
|
1852
1884
|
<div class="method-description">
|
1853
1885
|
<p>
|
1854
|
-
Returns the <a href="URI.html#
|
1886
|
+
Returns the <a href="URI.html#M000030">path</a> for this <a
|
1855
1887
|
href="URI.html">URI</a>.
|
1856
1888
|
</p>
|
1857
1889
|
<p><a class="source-toggle" href="#"
|
1858
|
-
onclick="toggleCode('
|
1859
|
-
<div class="method-source-code" id="
|
1890
|
+
onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
|
1891
|
+
<div class="method-source-code" id="M000030-source">
|
1860
1892
|
<pre>
|
1861
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1893
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 705</span>
|
1894
|
+
705: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">path</span>
|
1895
|
+
706: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@path</span>
|
1896
|
+
707: <span class="ruby-keyword kw">end</span>
|
1865
1897
|
</pre>
|
1866
1898
|
</div>
|
1867
1899
|
</div>
|
1868
1900
|
</div>
|
1869
1901
|
|
1870
|
-
<div id="method-
|
1871
|
-
<a name="
|
1902
|
+
<div id="method-M000031" class="method-detail">
|
1903
|
+
<a name="M000031"></a>
|
1872
1904
|
|
1873
1905
|
<div class="method-heading">
|
1874
|
-
<a href="#
|
1906
|
+
<a href="#M000031" class="method-signature">
|
1875
1907
|
<span class="method-name">path=</span><span class="method-args">(new_path)</span>
|
1876
1908
|
</a>
|
1877
1909
|
</div>
|
1878
1910
|
|
1879
1911
|
<div class="method-description">
|
1880
1912
|
<p>
|
1881
|
-
Sets the <a href="URI.html#
|
1913
|
+
Sets the <a href="URI.html#M000030">path</a> for this <a
|
1882
1914
|
href="URI.html">URI</a>.
|
1883
1915
|
</p>
|
1884
1916
|
<p><a class="source-toggle" href="#"
|
1885
|
-
onclick="toggleCode('
|
1886
|
-
<div class="method-source-code" id="
|
1917
|
+
onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
|
1918
|
+
<div class="method-source-code" id="M000031-source">
|
1887
1919
|
<pre>
|
1888
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1920
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 710</span>
|
1921
|
+
710: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">path=</span>(<span class="ruby-identifier">new_path</span>)
|
1922
|
+
711: <span class="ruby-ivar">@path</span> = (<span class="ruby-identifier">new_path</span> <span class="ruby-operator">||</span> <span class="ruby-value str">""</span>)
|
1923
|
+
712: <span class="ruby-keyword kw">end</span>
|
1892
1924
|
</pre>
|
1893
1925
|
</div>
|
1894
1926
|
</div>
|
1895
1927
|
</div>
|
1896
1928
|
|
1897
|
-
<div id="method-
|
1898
|
-
<a name="
|
1929
|
+
<div id="method-M000027" class="method-detail">
|
1930
|
+
<a name="M000027"></a>
|
1899
1931
|
|
1900
1932
|
<div class="method-heading">
|
1901
|
-
<a href="#
|
1933
|
+
<a href="#M000027" class="method-signature">
|
1902
1934
|
<span class="method-name">port</span><span class="method-args">()</span>
|
1903
1935
|
</a>
|
1904
1936
|
</div>
|
1905
1937
|
|
1906
1938
|
<div class="method-description">
|
1907
1939
|
<p>
|
1908
|
-
Returns the <a href="URI.html#
|
1940
|
+
Returns the <a href="URI.html#M000027">port</a> number for this <a
|
1909
1941
|
href="URI.html">URI</a>. This method will <a
|
1910
|
-
href="URI.html#
|
1911
|
-
href="URI.html#
|
1912
|
-
<a href="URI.html#
|
1913
|
-
href="URI.html#
|
1942
|
+
href="URI.html#M000048">normalize</a> to the default <a
|
1943
|
+
href="URI.html#M000027">port</a> for the <a href="URI.html">URI</a>‘s
|
1944
|
+
<a href="URI.html#M000013">scheme</a> if the <a
|
1945
|
+
href="URI.html#M000027">port</a> isn‘t explicitly specified in the <a
|
1914
1946
|
href="URI.html">URI</a>.
|
1915
1947
|
</p>
|
1916
1948
|
<p><a class="source-toggle" href="#"
|
1917
|
-
onclick="toggleCode('
|
1918
|
-
<div class="method-source-code" id="
|
1949
|
+
onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
|
1950
|
+
<div class="method-source-code" id="M000027-source">
|
1919
1951
|
<pre>
|
1920
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1952
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 673</span>
|
1953
|
+
673: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">port</span>
|
1954
|
+
674: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@port</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
1955
|
+
675: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>
|
1956
|
+
676: <span class="ruby-ivar">@port</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">scheme_mapping</span>[<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">downcase</span>]
|
1957
|
+
677: <span class="ruby-keyword kw">else</span>
|
1958
|
+
678: <span class="ruby-ivar">@port</span> = <span class="ruby-keyword kw">nil</span>
|
1959
|
+
679: <span class="ruby-keyword kw">end</span>
|
1960
|
+
680: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@port</span>
|
1961
|
+
681: <span class="ruby-keyword kw">else</span>
|
1962
|
+
682: <span class="ruby-ivar">@port</span> = <span class="ruby-ivar">@port</span>.<span class="ruby-identifier">to_i</span>
|
1963
|
+
683: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@port</span>
|
1964
|
+
684: <span class="ruby-keyword kw">end</span>
|
1965
|
+
685: <span class="ruby-keyword kw">end</span>
|
1934
1966
|
</pre>
|
1935
1967
|
</div>
|
1936
1968
|
</div>
|
1937
1969
|
</div>
|
1938
1970
|
|
1939
|
-
<div id="method-
|
1940
|
-
<a name="
|
1971
|
+
<div id="method-M000028" class="method-detail">
|
1972
|
+
<a name="M000028"></a>
|
1941
1973
|
|
1942
1974
|
<div class="method-heading">
|
1943
|
-
<a href="#
|
1975
|
+
<a href="#M000028" class="method-signature">
|
1944
1976
|
<span class="method-name">port=</span><span class="method-args">(new_port)</span>
|
1945
1977
|
</a>
|
1946
1978
|
</div>
|
1947
1979
|
|
1948
1980
|
<div class="method-description">
|
1949
1981
|
<p>
|
1950
|
-
Sets the <a href="URI.html#
|
1982
|
+
Sets the <a href="URI.html#M000027">port</a> for this <a
|
1951
1983
|
href="URI.html">URI</a>.
|
1952
1984
|
</p>
|
1953
1985
|
<p><a class="source-toggle" href="#"
|
1954
|
-
onclick="toggleCode('
|
1955
|
-
<div class="method-source-code" id="
|
1986
|
+
onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
|
1987
|
+
<div class="method-source-code" id="M000028-source">
|
1956
1988
|
<pre>
|
1957
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1989
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 688</span>
|
1990
|
+
688: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">port=</span>(<span class="ruby-identifier">new_port</span>)
|
1991
|
+
689: <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">new_port</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_i</span>
|
1992
|
+
690: <span class="ruby-ivar">@specified_port</span> = <span class="ruby-ivar">@port</span>
|
1993
|
+
691: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
|
1994
|
+
692: <span class="ruby-keyword kw">end</span>
|
1963
1995
|
</pre>
|
1964
1996
|
</div>
|
1965
1997
|
</div>
|
1966
1998
|
</div>
|
1967
1999
|
|
1968
|
-
<div id="method-
|
1969
|
-
<a name="
|
2000
|
+
<div id="method-M000034" class="method-detail">
|
2001
|
+
<a name="M000034"></a>
|
1970
2002
|
|
1971
2003
|
<div class="method-heading">
|
1972
|
-
<a href="#
|
2004
|
+
<a href="#M000034" class="method-signature">
|
1973
2005
|
<span class="method-name">query</span><span class="method-args">()</span>
|
1974
2006
|
</a>
|
1975
2007
|
</div>
|
1976
2008
|
|
1977
2009
|
<div class="method-description">
|
1978
2010
|
<p>
|
1979
|
-
Returns the <a href="URI.html#
|
2011
|
+
Returns the <a href="URI.html#M000034">query</a> string for this <a
|
1980
2012
|
href="URI.html">URI</a>.
|
1981
2013
|
</p>
|
1982
2014
|
<p><a class="source-toggle" href="#"
|
1983
|
-
onclick="toggleCode('
|
1984
|
-
<div class="method-source-code" id="
|
2015
|
+
onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
|
2016
|
+
<div class="method-source-code" id="M000034-source">
|
1985
2017
|
<pre>
|
1986
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
2018
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 730</span>
|
2019
|
+
730: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">query</span>
|
2020
|
+
731: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@query</span>
|
2021
|
+
732: <span class="ruby-keyword kw">end</span>
|
1990
2022
|
</pre>
|
1991
2023
|
</div>
|
1992
2024
|
</div>
|
1993
2025
|
</div>
|
1994
2026
|
|
1995
|
-
<div id="method-
|
1996
|
-
<a name="
|
2027
|
+
<div id="method-M000035" class="method-detail">
|
2028
|
+
<a name="M000035"></a>
|
1997
2029
|
|
1998
2030
|
<div class="method-heading">
|
1999
|
-
<a href="#
|
2031
|
+
<a href="#M000035" class="method-signature">
|
2000
2032
|
<span class="method-name">query=</span><span class="method-args">(new_query)</span>
|
2001
2033
|
</a>
|
2002
2034
|
</div>
|
2003
2035
|
|
2004
2036
|
<div class="method-description">
|
2005
2037
|
<p>
|
2006
|
-
Sets the <a href="URI.html#
|
2038
|
+
Sets the <a href="URI.html#M000034">query</a> string for this <a
|
2007
2039
|
href="URI.html">URI</a>.
|
2008
2040
|
</p>
|
2009
2041
|
<p><a class="source-toggle" href="#"
|
2010
|
-
onclick="toggleCode('
|
2011
|
-
<div class="method-source-code" id="
|
2042
|
+
onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
|
2043
|
+
<div class="method-source-code" id="M000035-source">
|
2012
2044
|
<pre>
|
2013
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2045
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 735</span>
|
2046
|
+
735: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">query=</span>(<span class="ruby-identifier">new_query</span>)
|
2047
|
+
736: <span class="ruby-ivar">@query</span> = <span class="ruby-identifier">new_query</span>
|
2048
|
+
737: <span class="ruby-keyword kw">end</span>
|
2017
2049
|
</pre>
|
2018
2050
|
</div>
|
2019
2051
|
</div>
|
2020
2052
|
</div>
|
2021
2053
|
|
2022
|
-
<div id="method-
|
2023
|
-
<a name="
|
2054
|
+
<div id="method-M000039" class="method-detail">
|
2055
|
+
<a name="M000039"></a>
|
2024
2056
|
|
2025
2057
|
<div class="method-heading">
|
2026
|
-
<a href="#
|
2058
|
+
<a href="#M000039" class="method-signature">
|
2027
2059
|
<span class="method-name">relative?</span><span class="method-args">()</span>
|
2028
2060
|
</a>
|
2029
2061
|
</div>
|
@@ -2033,23 +2065,23 @@ href="URI.html">URI</a>.
|
|
2033
2065
|
Returns true if this <a href="URI.html">URI</a> is known to be relative.
|
2034
2066
|
</p>
|
2035
2067
|
<p><a class="source-toggle" href="#"
|
2036
|
-
onclick="toggleCode('
|
2037
|
-
<div class="method-source-code" id="
|
2068
|
+
onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
|
2069
|
+
<div class="method-source-code" id="M000039-source">
|
2038
2070
|
<pre>
|
2039
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2071
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 759</span>
|
2072
|
+
759: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">relative?</span>
|
2073
|
+
760: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">nil?</span>
|
2074
|
+
761: <span class="ruby-keyword kw">end</span>
|
2043
2075
|
</pre>
|
2044
2076
|
</div>
|
2045
2077
|
</div>
|
2046
2078
|
</div>
|
2047
2079
|
|
2048
|
-
<div id="method-
|
2049
|
-
<a name="
|
2080
|
+
<div id="method-M000046" class="method-detail">
|
2081
|
+
<a name="M000046"></a>
|
2050
2082
|
|
2051
2083
|
<div class="method-heading">
|
2052
|
-
<a href="#
|
2084
|
+
<a href="#M000046" class="method-signature">
|
2053
2085
|
<span class="method-name">route_from</span><span class="method-args">(uri)</span>
|
2054
2086
|
</a>
|
2055
2087
|
</div>
|
@@ -2062,64 +2094,68 @@ as a base for resolution. Returns an absolute <a href="URI.html">URI</a> if
|
|
2062
2094
|
necessary.
|
2063
2095
|
</p>
|
2064
2096
|
<p><a class="source-toggle" href="#"
|
2065
|
-
onclick="toggleCode('
|
2066
|
-
<div class="method-source-code" id="
|
2097
|
+
onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
|
2098
|
+
<div class="method-source-code" id="M000046-source">
|
2067
2099
|
<pre>
|
2068
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
864: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-node">"##{normalized_self.fragment}"</span>)
|
2081
|
-
865: <span class="ruby-keyword kw">end</span>
|
2082
|
-
866: <span class="ruby-identifier">segments</span> = <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">to_h</span>
|
2083
|
-
867: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span>
|
2084
|
-
868: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>] = <span class="ruby-keyword kw">nil</span>
|
2085
|
-
869: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">authority</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">authority</span>
|
2086
|
-
870: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:user</span>] = <span class="ruby-keyword kw">nil</span>
|
2087
|
-
871: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:password</span>] = <span class="ruby-keyword kw">nil</span>
|
2088
|
-
872: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:host</span>] = <span class="ruby-keyword kw">nil</span>
|
2089
|
-
873: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:port</span>] = <span class="ruby-keyword kw">nil</span>
|
2090
|
-
874: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>
|
2091
|
-
875: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:path</span>] = <span class="ruby-keyword kw">nil</span>
|
2092
|
-
876: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">query</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
|
2093
|
-
877: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:query</span>] = <span class="ruby-keyword kw">nil</span>
|
2094
|
-
878: <span class="ruby-keyword kw">end</span>
|
2095
|
-
879: <span class="ruby-keyword kw">end</span>
|
2096
|
-
880: <span class="ruby-keyword kw">end</span>
|
2097
|
-
881: <span class="ruby-keyword kw">end</span>
|
2098
|
-
882: <span class="ruby-comment cmt"># Avoid network-path references.</span>
|
2099
|
-
883: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:host</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
2100
|
-
884: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>] = <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">scheme</span>
|
2100
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 874</span>
|
2101
|
+
874: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">route_from</span>(<span class="ruby-identifier">uri</span>)
|
2102
|
+
875: <span class="ruby-identifier">uri</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">normalize</span>
|
2103
|
+
876: <span class="ruby-identifier">normalized_self</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalize</span>
|
2104
|
+
877: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">relative?</span>
|
2105
|
+
878: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"Expected absolute URI, got: #{self.to_s}"</span>
|
2106
|
+
879: <span class="ruby-keyword kw">end</span>
|
2107
|
+
880: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">relative?</span>
|
2108
|
+
881: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"Expected absolute URI, got: #{uri.to_s}"</span>
|
2109
|
+
882: <span class="ruby-keyword kw">end</span>
|
2110
|
+
883: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>
|
2111
|
+
884: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-node">"##{normalized_self.fragment}"</span>)
|
2101
2112
|
885: <span class="ruby-keyword kw">end</span>
|
2102
|
-
886: <span class="ruby-
|
2103
|
-
887:
|
2104
|
-
888: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:
|
2105
|
-
889: <span class="ruby-identifier">
|
2106
|
-
890:
|
2107
|
-
891:
|
2108
|
-
892:
|
2109
|
-
893:
|
2110
|
-
894:
|
2111
|
-
895:
|
2112
|
-
896:
|
2113
|
+
886: <span class="ruby-identifier">segments</span> = <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">to_hash</span>
|
2114
|
+
887: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span>
|
2115
|
+
888: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>] = <span class="ruby-keyword kw">nil</span>
|
2116
|
+
889: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">authority</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">authority</span>
|
2117
|
+
890: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:user</span>] = <span class="ruby-keyword kw">nil</span>
|
2118
|
+
891: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:password</span>] = <span class="ruby-keyword kw">nil</span>
|
2119
|
+
892: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:host</span>] = <span class="ruby-keyword kw">nil</span>
|
2120
|
+
893: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:port</span>] = <span class="ruby-keyword kw">nil</span>
|
2121
|
+
894: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>
|
2122
|
+
895: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:path</span>] = <span class="ruby-keyword kw">nil</span>
|
2123
|
+
896: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">query</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
|
2124
|
+
897: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:query</span>] = <span class="ruby-keyword kw">nil</span>
|
2125
|
+
898: <span class="ruby-keyword kw">end</span>
|
2126
|
+
899: <span class="ruby-keyword kw">else</span>
|
2127
|
+
900: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">"/"</span>
|
2128
|
+
901: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:path</span>].<span class="ruby-identifier">gsub!</span>(
|
2129
|
+
902: <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"^"</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>)), <span class="ruby-value str">""</span>)
|
2130
|
+
903: <span class="ruby-keyword kw">end</span>
|
2131
|
+
904: <span class="ruby-keyword kw">end</span>
|
2132
|
+
905: <span class="ruby-keyword kw">end</span>
|
2133
|
+
906: <span class="ruby-keyword kw">end</span>
|
2134
|
+
907: <span class="ruby-comment cmt"># Avoid network-path references.</span>
|
2135
|
+
908: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:host</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
2136
|
+
909: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>] = <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">scheme</span>
|
2137
|
+
910: <span class="ruby-keyword kw">end</span>
|
2138
|
+
911: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Addressable</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>(
|
2139
|
+
912: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>],
|
2140
|
+
913: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:user</span>],
|
2141
|
+
914: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:password</span>],
|
2142
|
+
915: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:host</span>],
|
2143
|
+
916: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:port</span>],
|
2144
|
+
917: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:path</span>],
|
2145
|
+
918: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:query</span>],
|
2146
|
+
919: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:fragment</span>]
|
2147
|
+
920: )
|
2148
|
+
921: <span class="ruby-keyword kw">end</span>
|
2113
2149
|
</pre>
|
2114
2150
|
</div>
|
2115
2151
|
</div>
|
2116
2152
|
</div>
|
2117
2153
|
|
2118
|
-
<div id="method-
|
2119
|
-
<a name="
|
2154
|
+
<div id="method-M000047" class="method-detail">
|
2155
|
+
<a name="M000047"></a>
|
2120
2156
|
|
2121
2157
|
<div class="method-heading">
|
2122
|
-
<a href="#
|
2158
|
+
<a href="#M000047" class="method-signature">
|
2123
2159
|
<span class="method-name">route_to</span><span class="method-args">(uri)</span>
|
2124
2160
|
</a>
|
2125
2161
|
</div>
|
@@ -2132,111 +2168,110 @@ for resolution. Returns an absolute <a href="URI.html">URI</a> if
|
|
2132
2168
|
necessary.
|
2133
2169
|
</p>
|
2134
2170
|
<p><a class="source-toggle" href="#"
|
2135
|
-
onclick="toggleCode('
|
2136
|
-
<div class="method-source-code" id="
|
2171
|
+
onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
|
2172
|
+
<div class="method-source-code" id="M000047-source">
|
2137
2173
|
<pre>
|
2138
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
904: <span class="ruby-keyword kw">end</span>
|
2174
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 926</span>
|
2175
|
+
926: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">route_to</span>(<span class="ruby-identifier">uri</span>)
|
2176
|
+
927: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">route_from</span>(<span class="ruby-keyword kw">self</span>)
|
2177
|
+
928: <span class="ruby-keyword kw">end</span>
|
2143
2178
|
</pre>
|
2144
2179
|
</div>
|
2145
2180
|
</div>
|
2146
2181
|
</div>
|
2147
2182
|
|
2148
|
-
<div id="method-
|
2149
|
-
<a name="
|
2183
|
+
<div id="method-M000013" class="method-detail">
|
2184
|
+
<a name="M000013"></a>
|
2150
2185
|
|
2151
2186
|
<div class="method-heading">
|
2152
|
-
<a href="#
|
2187
|
+
<a href="#M000013" class="method-signature">
|
2153
2188
|
<span class="method-name">scheme</span><span class="method-args">()</span>
|
2154
2189
|
</a>
|
2155
2190
|
</div>
|
2156
2191
|
|
2157
2192
|
<div class="method-description">
|
2158
2193
|
<p>
|
2159
|
-
Returns the <a href="URI.html#
|
2194
|
+
Returns the <a href="URI.html#M000013">scheme</a> (protocol) for this <a
|
2160
2195
|
href="URI.html">URI</a>.
|
2161
2196
|
</p>
|
2162
2197
|
<p><a class="source-toggle" href="#"
|
2163
|
-
onclick="toggleCode('
|
2164
|
-
<div class="method-source-code" id="
|
2198
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
2199
|
+
<div class="method-source-code" id="M000013-source">
|
2165
2200
|
<pre>
|
2166
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2201
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 496</span>
|
2202
|
+
496: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">scheme</span>
|
2203
|
+
497: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@scheme</span>
|
2204
|
+
498: <span class="ruby-keyword kw">end</span>
|
2170
2205
|
</pre>
|
2171
2206
|
</div>
|
2172
2207
|
</div>
|
2173
2208
|
</div>
|
2174
2209
|
|
2175
|
-
<div id="method-
|
2176
|
-
<a name="
|
2210
|
+
<div id="method-M000014" class="method-detail">
|
2211
|
+
<a name="M000014"></a>
|
2177
2212
|
|
2178
2213
|
<div class="method-heading">
|
2179
|
-
<a href="#
|
2214
|
+
<a href="#M000014" class="method-signature">
|
2180
2215
|
<span class="method-name">scheme=</span><span class="method-args">(new_scheme)</span>
|
2181
2216
|
</a>
|
2182
2217
|
</div>
|
2183
2218
|
|
2184
2219
|
<div class="method-description">
|
2185
2220
|
<p>
|
2186
|
-
Sets the <a href="URI.html#
|
2221
|
+
Sets the <a href="URI.html#M000013">scheme</a> (protocol for this <a
|
2187
2222
|
href="URI.html">URI</a>.)
|
2188
2223
|
</p>
|
2189
2224
|
<p><a class="source-toggle" href="#"
|
2190
|
-
onclick="toggleCode('
|
2191
|
-
<div class="method-source-code" id="
|
2225
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
2226
|
+
<div class="method-source-code" id="M000014-source">
|
2192
2227
|
<pre>
|
2193
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2228
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 501</span>
|
2229
|
+
501: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">scheme=</span>(<span class="ruby-identifier">new_scheme</span>)
|
2230
|
+
502: <span class="ruby-ivar">@scheme</span> = <span class="ruby-identifier">new_scheme</span>
|
2231
|
+
503: <span class="ruby-keyword kw">end</span>
|
2197
2232
|
</pre>
|
2198
2233
|
</div>
|
2199
2234
|
</div>
|
2200
2235
|
</div>
|
2201
2236
|
|
2202
|
-
<div id="method-
|
2203
|
-
<a name="
|
2237
|
+
<div id="method-M000029" class="method-detail">
|
2238
|
+
<a name="M000029"></a>
|
2204
2239
|
|
2205
2240
|
<div class="method-heading">
|
2206
|
-
<a href="#
|
2241
|
+
<a href="#M000029" class="method-signature">
|
2207
2242
|
<span class="method-name">specified_port</span><span class="method-args">()</span>
|
2208
2243
|
</a>
|
2209
2244
|
</div>
|
2210
2245
|
|
2211
2246
|
<div class="method-description">
|
2212
2247
|
<p>
|
2213
|
-
Returns the <a href="URI.html#
|
2248
|
+
Returns the <a href="URI.html#M000027">port</a> number that was actually
|
2214
2249
|
specified in the <a href="URI.html">URI</a> string.
|
2215
2250
|
</p>
|
2216
2251
|
<p><a class="source-toggle" href="#"
|
2217
|
-
onclick="toggleCode('
|
2218
|
-
<div class="method-source-code" id="
|
2252
|
+
onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
|
2253
|
+
<div class="method-source-code" id="M000029-source">
|
2219
2254
|
<pre>
|
2220
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2255
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 695</span>
|
2256
|
+
695: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">specified_port</span>
|
2257
|
+
696: <span class="ruby-identifier">port</span> = <span class="ruby-ivar">@specified_port</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_i</span>
|
2258
|
+
697: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">port</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
2259
|
+
698: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
|
2260
|
+
699: <span class="ruby-keyword kw">else</span>
|
2261
|
+
700: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">port</span>
|
2262
|
+
701: <span class="ruby-keyword kw">end</span>
|
2263
|
+
702: <span class="ruby-keyword kw">end</span>
|
2229
2264
|
</pre>
|
2230
2265
|
</div>
|
2231
2266
|
</div>
|
2232
2267
|
</div>
|
2233
2268
|
|
2234
|
-
<div id="method-
|
2235
|
-
<a name="
|
2269
|
+
<div id="method-M000056" class="method-detail">
|
2270
|
+
<a name="M000056"></a>
|
2236
2271
|
|
2237
2272
|
<div class="method-heading">
|
2238
|
-
<a href="#
|
2239
|
-
<span class="method-name">
|
2273
|
+
<a href="#M000056" class="method-signature">
|
2274
|
+
<span class="method-name">to_hash</span><span class="method-args">()</span>
|
2240
2275
|
</a>
|
2241
2276
|
</div>
|
2242
2277
|
|
@@ -2245,32 +2280,32 @@ specified in the <a href="URI.html">URI</a> string.
|
|
2245
2280
|
Returns a Hash of the <a href="URI.html">URI</a> segments.
|
2246
2281
|
</p>
|
2247
2282
|
<p><a class="source-toggle" href="#"
|
2248
|
-
onclick="toggleCode('
|
2249
|
-
<div class="method-source-code" id="
|
2283
|
+
onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
|
2284
|
+
<div class="method-source-code" id="M000056-source">
|
2250
2285
|
<pre>
|
2251
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2286
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1090</span>
|
2287
|
+
1090: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
|
2288
|
+
1091: <span class="ruby-keyword kw">return</span> {
|
2289
|
+
1092: <span class="ruby-identifier">:scheme</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>,
|
2290
|
+
1093: <span class="ruby-identifier">:user</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span>,
|
2291
|
+
1094: <span class="ruby-identifier">:password</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>,
|
2292
|
+
1095: <span class="ruby-identifier">:host</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>,
|
2293
|
+
1096: <span class="ruby-identifier">:port</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">specified_port</span>,
|
2294
|
+
1097: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>,
|
2295
|
+
1098: <span class="ruby-identifier">:query</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>,
|
2296
|
+
1099: <span class="ruby-identifier">:fragment</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fragment</span>
|
2297
|
+
1100: }
|
2298
|
+
1101: <span class="ruby-keyword kw">end</span>
|
2264
2299
|
</pre>
|
2265
2300
|
</div>
|
2266
2301
|
</div>
|
2267
2302
|
</div>
|
2268
2303
|
|
2269
|
-
<div id="method-
|
2270
|
-
<a name="
|
2304
|
+
<div id="method-M000055" class="method-detail">
|
2305
|
+
<a name="M000055"></a>
|
2271
2306
|
|
2272
2307
|
<div class="method-heading">
|
2273
|
-
<a href="#
|
2308
|
+
<a href="#M000055" class="method-signature">
|
2274
2309
|
<span class="method-name">to_s</span><span class="method-args">()</span>
|
2275
2310
|
</a>
|
2276
2311
|
</div>
|
@@ -2280,161 +2315,161 @@ Returns a Hash of the <a href="URI.html">URI</a> segments.
|
|
2280
2315
|
Returns the assembled <a href="URI.html">URI</a> as a string.
|
2281
2316
|
</p>
|
2282
2317
|
<p><a class="source-toggle" href="#"
|
2283
|
-
onclick="toggleCode('
|
2284
|
-
<div class="method-source-code" id="
|
2318
|
+
onclick="toggleCode('M000055-source');return false;">[Source]</a></p>
|
2319
|
+
<div class="method-source-code" id="M000055-source">
|
2285
2320
|
<pre>
|
2286
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2295
|
-
|
2321
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1079</span>
|
2322
|
+
1079: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
2323
|
+
1080: <span class="ruby-identifier">uri_string</span> = <span class="ruby-value str">""</span>
|
2324
|
+
1081: <span class="ruby-identifier">uri_string</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{self.scheme}:"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
2325
|
+
1082: <span class="ruby-identifier">uri_string</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"//#{self.authority}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">authority</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
2326
|
+
1083: <span class="ruby-identifier">uri_string</span> <span class="ruby-operator"><<</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">to_s</span>
|
2327
|
+
1084: <span class="ruby-identifier">uri_string</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"?#{self.query}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
2328
|
+
1085: <span class="ruby-identifier">uri_string</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"##{self.fragment}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fragment</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
2329
|
+
1086: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">uri_string</span>
|
2330
|
+
1087: <span class="ruby-keyword kw">end</span>
|
2296
2331
|
</pre>
|
2297
2332
|
</div>
|
2298
2333
|
</div>
|
2299
2334
|
</div>
|
2300
2335
|
|
2301
|
-
<div id="method-
|
2302
|
-
<a name="
|
2336
|
+
<div id="method-M000015" class="method-detail">
|
2337
|
+
<a name="M000015"></a>
|
2303
2338
|
|
2304
2339
|
<div class="method-heading">
|
2305
|
-
<a href="#
|
2340
|
+
<a href="#M000015" class="method-signature">
|
2306
2341
|
<span class="method-name">user</span><span class="method-args">()</span>
|
2307
2342
|
</a>
|
2308
2343
|
</div>
|
2309
2344
|
|
2310
2345
|
<div class="method-description">
|
2311
2346
|
<p>
|
2312
|
-
Returns the <a href="URI.html#
|
2347
|
+
Returns the <a href="URI.html#M000015">user</a> for this <a
|
2313
2348
|
href="URI.html">URI</a>.
|
2314
2349
|
</p>
|
2315
2350
|
<p><a class="source-toggle" href="#"
|
2316
|
-
onclick="toggleCode('
|
2317
|
-
<div class="method-source-code" id="
|
2351
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
2352
|
+
<div class="method-source-code" id="M000015-source">
|
2318
2353
|
<pre>
|
2319
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2354
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 506</span>
|
2355
|
+
506: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">user</span>
|
2356
|
+
507: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@user</span>
|
2357
|
+
508: <span class="ruby-keyword kw">end</span>
|
2323
2358
|
</pre>
|
2324
2359
|
</div>
|
2325
2360
|
</div>
|
2326
2361
|
</div>
|
2327
2362
|
|
2328
|
-
<div id="method-
|
2329
|
-
<a name="
|
2363
|
+
<div id="method-M000016" class="method-detail">
|
2364
|
+
<a name="M000016"></a>
|
2330
2365
|
|
2331
2366
|
<div class="method-heading">
|
2332
|
-
<a href="#
|
2367
|
+
<a href="#M000016" class="method-signature">
|
2333
2368
|
<span class="method-name">user=</span><span class="method-args">(new_user)</span>
|
2334
2369
|
</a>
|
2335
2370
|
</div>
|
2336
2371
|
|
2337
2372
|
<div class="method-description">
|
2338
2373
|
<p>
|
2339
|
-
Sets the <a href="URI.html#
|
2374
|
+
Sets the <a href="URI.html#M000015">user</a> for this <a
|
2340
2375
|
href="URI.html">URI</a>.
|
2341
2376
|
</p>
|
2342
2377
|
<p><a class="source-toggle" href="#"
|
2343
|
-
onclick="toggleCode('
|
2344
|
-
<div class="method-source-code" id="
|
2378
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
2379
|
+
<div class="method-source-code" id="M000016-source">
|
2345
2380
|
<pre>
|
2346
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2347
|
-
|
2348
|
-
|
2349
|
-
|
2350
|
-
|
2351
|
-
|
2352
|
-
|
2353
|
-
|
2354
|
-
|
2355
|
-
|
2356
|
-
|
2357
|
-
|
2358
|
-
|
2359
|
-
|
2360
|
-
|
2361
|
-
|
2381
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 511</span>
|
2382
|
+
511: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">user=</span>(<span class="ruby-identifier">new_user</span>)
|
2383
|
+
512: <span class="ruby-ivar">@user</span> = <span class="ruby-identifier">new_user</span>
|
2384
|
+
513:
|
2385
|
+
514: <span class="ruby-comment cmt"># You can't have a nil user with a non-nil password</span>
|
2386
|
+
515: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@password</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
2387
|
+
516: <span class="ruby-ivar">@user</span> = <span class="ruby-value str">""</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@user</span>.<span class="ruby-identifier">nil?</span>
|
2388
|
+
517: <span class="ruby-keyword kw">end</span>
|
2389
|
+
518:
|
2390
|
+
519: <span class="ruby-comment cmt"># Reset dependant values</span>
|
2391
|
+
520: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-keyword kw">nil</span>
|
2392
|
+
521: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
|
2393
|
+
522:
|
2394
|
+
523: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
|
2395
|
+
524: <span class="ruby-identifier">validate</span>()
|
2396
|
+
525: <span class="ruby-keyword kw">end</span>
|
2362
2397
|
</pre>
|
2363
2398
|
</div>
|
2364
2399
|
</div>
|
2365
2400
|
</div>
|
2366
2401
|
|
2367
|
-
<div id="method-
|
2368
|
-
<a name="
|
2402
|
+
<div id="method-M000019" class="method-detail">
|
2403
|
+
<a name="M000019"></a>
|
2369
2404
|
|
2370
2405
|
<div class="method-heading">
|
2371
|
-
<a href="#
|
2406
|
+
<a href="#M000019" class="method-signature">
|
2372
2407
|
<span class="method-name">userinfo</span><span class="method-args">()</span>
|
2373
2408
|
</a>
|
2374
2409
|
</div>
|
2375
2410
|
|
2376
2411
|
<div class="method-description">
|
2377
2412
|
<p>
|
2378
|
-
Returns the username and <a href="URI.html#
|
2413
|
+
Returns the username and <a href="URI.html#M000017">password</a> segment of
|
2379
2414
|
this <a href="URI.html">URI</a>.
|
2380
2415
|
</p>
|
2381
2416
|
<p><a class="source-toggle" href="#"
|
2382
|
-
onclick="toggleCode('
|
2383
|
-
<div class="method-source-code" id="
|
2417
|
+
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
2418
|
+
<div class="method-source-code" id="M000019-source">
|
2384
2419
|
<pre>
|
2385
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2420
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 550</span>
|
2421
|
+
550: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">userinfo</span>
|
2422
|
+
551: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword kw">defined?</span>(<span class="ruby-ivar">@userinfo</span>) <span class="ruby-operator">||</span> <span class="ruby-ivar">@userinfo</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
|
2423
|
+
552: <span class="ruby-identifier">current_user</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span>
|
2424
|
+
553: <span class="ruby-identifier">current_password</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>
|
2425
|
+
554: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">current_user</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">current_password</span>
|
2426
|
+
555: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-keyword kw">nil</span>
|
2427
|
+
556: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">current_user</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">current_password</span>
|
2428
|
+
557: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-node">"#{current_user}:#{current_password}"</span>
|
2429
|
+
558: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">current_user</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">current_password</span>
|
2430
|
+
559: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-node">"#{current_user}"</span>
|
2431
|
+
560: <span class="ruby-keyword kw">end</span>
|
2432
|
+
561: <span class="ruby-keyword kw">end</span>
|
2433
|
+
562: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@userinfo</span>
|
2434
|
+
563: <span class="ruby-keyword kw">end</span>
|
2400
2435
|
</pre>
|
2401
2436
|
</div>
|
2402
2437
|
</div>
|
2403
2438
|
</div>
|
2404
2439
|
|
2405
|
-
<div id="method-
|
2406
|
-
<a name="
|
2440
|
+
<div id="method-M000020" class="method-detail">
|
2441
|
+
<a name="M000020"></a>
|
2407
2442
|
|
2408
2443
|
<div class="method-heading">
|
2409
|
-
<a href="#
|
2444
|
+
<a href="#M000020" class="method-signature">
|
2410
2445
|
<span class="method-name">userinfo=</span><span class="method-args">(new_userinfo)</span>
|
2411
2446
|
</a>
|
2412
2447
|
</div>
|
2413
2448
|
|
2414
2449
|
<div class="method-description">
|
2415
2450
|
<p>
|
2416
|
-
Sets the username and <a href="URI.html#
|
2451
|
+
Sets the username and <a href="URI.html#M000017">password</a> segment of
|
2417
2452
|
this <a href="URI.html">URI</a>.
|
2418
2453
|
</p>
|
2419
2454
|
<p><a class="source-toggle" href="#"
|
2420
|
-
onclick="toggleCode('
|
2421
|
-
<div class="method-source-code" id="
|
2455
|
+
onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
|
2456
|
+
<div class="method-source-code" id="M000020-source">
|
2422
2457
|
<pre>
|
2423
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2424
|
-
|
2425
|
-
|
2426
|
-
|
2427
|
-
|
2428
|
-
|
2429
|
-
|
2430
|
-
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2458
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 566</span>
|
2459
|
+
566: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">userinfo=</span>(<span class="ruby-identifier">new_userinfo</span>)
|
2460
|
+
567: <span class="ruby-identifier">new_user</span> = <span class="ruby-identifier">new_userinfo</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/^(.*):/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
|
2461
|
+
568: <span class="ruby-identifier">new_password</span> = <span class="ruby-identifier">new_userinfo</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/:(.*)$/</span>).<span class="ruby-identifier">flatten</span>[<span class="ruby-value">0</span>]
|
2462
|
+
569:
|
2463
|
+
570: <span class="ruby-comment cmt"># Password assigned first to ensure validity in case of nil</span>
|
2464
|
+
571: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span> = <span class="ruby-identifier">new_password</span>
|
2465
|
+
572: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span> = <span class="ruby-identifier">new_user</span>
|
2466
|
+
573:
|
2467
|
+
574: <span class="ruby-comment cmt"># Reset dependant values</span>
|
2468
|
+
575: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
|
2469
|
+
576:
|
2470
|
+
577: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
|
2471
|
+
578: <span class="ruby-identifier">validate</span>()
|
2472
|
+
579: <span class="ruby-keyword kw">end</span>
|
2438
2473
|
</pre>
|
2439
2474
|
</div>
|
2440
2475
|
</div>
|