addressable 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/coverage/index.html +5 -5
- data/coverage/lib-addressable-uri_rb.html +949 -933
- data/coverage/lib-addressable-version_rb.html +2 -2
- data/doc/classes/Addressable/URI.html +758 -742
- data/doc/classes/Addressable/URI/IDNA.html +22 -22
- data/doc/created.rid +1 -1
- data/doc/files/CHANGELOG.html +6 -2
- data/doc/files/lib/addressable/uri_rb.html +1 -1
- data/doc/files/lib/addressable/version_rb.html +1 -1
- data/lib/addressable/uri.rb +19 -3
- data/lib/addressable/version.rb +1 -1
- data/spec/addressable/uri_spec.rb +32 -0
- data/specdoc/index.html +427 -411
- metadata +2 -2
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on
|
556
|
+
<p>Generated on Thu Dec 13 13:10:50 -0500 2007 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -625,7 +625,7 @@ span.run100 {
|
|
625
625
|
</span><span class="marked1"><a name="line25"></a>25 module ADDRESSABLE_VERSION #:nodoc:
|
626
626
|
</span><span class="marked0"><a name="line26"></a>26 MAJOR = 1
|
627
627
|
</span><span class="marked1"><a name="line27"></a>27 MINOR = 0
|
628
|
-
</span><span class="marked0"><a name="line28"></a>28 TINY =
|
628
|
+
</span><span class="marked0"><a name="line28"></a>28 TINY = 2
|
629
629
|
</span><span class="inferred1"><a name="line29"></a>29
|
630
630
|
</span><span class="marked0"><a name="line30"></a>30 STRING = [MAJOR, MINOR, TINY].join('.')
|
631
631
|
</span><span class="inferred1"><a name="line31"></a>31 end
|
@@ -268,28 +268,28 @@ This method does not take IRIs or IDNs into account.
|
|
268
268
|
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
269
269
|
<div class="method-source-code" id="M000009-source">
|
270
270
|
<pre>
|
271
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
271
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 373</span>
|
272
|
+
373: <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
|
+
374: <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
|
+
375: <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
|
+
376: <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
|
+
377: <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
|
+
378: <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
|
+
379: <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
|
+
380: <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
|
+
381: <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
|
+
382: <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
|
+
383: <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
|
+
384: <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
|
+
385: <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
|
+
386: <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
|
+
387: <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
|
+
388: <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
|
+
389: <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
|
+
390: <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
|
+
391: <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
|
+
392: ).<span class="ruby-identifier">to_s</span>
|
292
|
+
393: <span class="ruby-keyword kw">end</span>
|
293
293
|
</pre>
|
294
294
|
</div>
|
295
295
|
</div>
|
@@ -326,17 +326,17 @@ An example:
|
|
326
326
|
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
327
327
|
<div class="method-source-code" id="M000007-source">
|
328
328
|
<pre>
|
329
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
329
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 351</span>
|
330
|
+
351: <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
|
+
352: <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
|
+
353: <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
|
+
354: <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
|
+
355: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">segment</span>.<span class="ruby-identifier">gsub</span>(
|
335
|
+
356: <span class="ruby-node">/[^#{character_class}]/</span>
|
336
|
+
357: ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">sequence</span><span class="ruby-operator">|</span>
|
337
|
+
358: (<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
|
+
359: <span class="ruby-keyword kw">end</span>
|
339
|
+
360: <span class="ruby-keyword kw">end</span>
|
340
340
|
</pre>
|
341
341
|
</div>
|
342
342
|
</div>
|
@@ -440,58 +440,58 @@ Extracts uris from an arbitrary body of text.
|
|
440
440
|
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
441
441
|
<div class="method-source-code" id="M000011-source">
|
442
442
|
<pre>
|
443
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
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
|
-
456: <span class="ruby-keyword kw">end</span>
|
478
|
-
457: <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
|
-
458: (<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
|
-
459: <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
|
-
460: <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
|
-
461: <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
|
-
462: <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
|
-
463: <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
|
-
464: <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
|
-
465: <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
|
-
466: <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
|
-
467: <span class="ruby-keyword kw">end</span>
|
489
|
-
468: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:parse</span>]
|
490
|
-
469: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">parsed_uris</span>
|
491
|
-
470: <span class="ruby-keyword kw">else</span>
|
492
|
-
471: <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> }
|
443
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 439</span>
|
444
|
+
439: <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
|
+
440: <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
|
+
441: <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
|
+
442: <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
|
+
443: <span class="ruby-comment cmt"># This regular expression needs to be less forgiving or else it would</span>
|
449
|
+
444: <span class="ruby-comment cmt"># match virtually all text. Which isn't exactly what we're going for.</span>
|
450
|
+
445: <span class="ruby-identifier">extract_regex</span> = <span class="ruby-regexp re">/((([a-z\+]+):)[^ \n\<\>\"\\]+[\w\/])/</span>
|
451
|
+
446: <span class="ruby-identifier">extracted_uris</span> =
|
452
|
+
447: <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
|
+
448: <span class="ruby-identifier">sgml_extract_regex</span> = <span class="ruby-regexp re">/<[^>]+href=\"([^\"]+?)\"[^>]*>/</span>
|
454
|
+
449: <span class="ruby-identifier">sgml_extracted_uris</span> =
|
455
|
+
450: <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
|
+
451: <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
|
+
452: <span class="ruby-identifier">textile_extract_regex</span> = <span class="ruby-regexp re">/\".+?\":([^ ]+\/[^ ]+)[ \,\.\;\:\?\!\<\>\"]/i</span>
|
458
|
+
453: <span class="ruby-identifier">textile_extracted_uris</span> =
|
459
|
+
454: <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
|
+
455: <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
|
+
456: <span class="ruby-identifier">parsed_uris</span> = []
|
462
|
+
457: <span class="ruby-identifier">base_uri</span> = <span class="ruby-keyword kw">nil</span>
|
463
|
+
458: <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
|
+
459: <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
|
+
460: <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
|
+
461: <span class="ruby-keyword kw">end</span>
|
467
|
+
462: <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
|
+
463: <span class="ruby-keyword kw">begin</span>
|
469
|
+
464: <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
|
+
465: <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
|
+
466: <span class="ruby-keyword kw">else</span>
|
472
|
+
467: <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
|
+
468: <span class="ruby-keyword kw">end</span>
|
474
|
+
469: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
|
475
|
+
470: <span class="ruby-keyword kw">nil</span>
|
476
|
+
471: <span class="ruby-keyword kw">end</span>
|
493
477
|
472: <span class="ruby-keyword kw">end</span>
|
494
|
-
473:
|
478
|
+
473: <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
|
+
474: (<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
|
+
475: <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
|
+
476: <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
|
+
477: <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
|
+
478: <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
|
+
479: <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
|
+
480: <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
|
+
481: <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
|
+
482: <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
|
+
483: <span class="ruby-keyword kw">end</span>
|
489
|
+
484: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:parse</span>]
|
490
|
+
485: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">parsed_uris</span>
|
491
|
+
486: <span class="ruby-keyword kw">else</span>
|
492
|
+
487: <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
|
+
488: <span class="ruby-keyword kw">end</span>
|
494
|
+
489: <span class="ruby-keyword kw">end</span>
|
495
495
|
</pre>
|
496
496
|
</div>
|
497
497
|
</div>
|
@@ -580,10 +580,10 @@ href="URI.html#M000030">path</a>>
|
|
580
580
|
onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
|
581
581
|
<div class="method-source-code" id="M000025-source">
|
582
582
|
<pre>
|
583
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
584
|
-
|
585
|
-
|
586
|
-
|
583
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 662</span>
|
584
|
+
662: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">ip_based_schemes</span>
|
585
|
+
663: <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
|
+
664: <span class="ruby-keyword kw">end</span>
|
587
587
|
</pre>
|
588
588
|
</div>
|
589
589
|
</div>
|
@@ -606,17 +606,17 @@ Joins several uris together.
|
|
606
606
|
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
607
607
|
<div class="method-source-code" id="M000006-source">
|
608
608
|
<pre>
|
609
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
609
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 328</span>
|
610
|
+
328: <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
|
+
329: <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
|
+
330: <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
|
+
331: <span class="ruby-keyword kw">end</span>
|
614
|
+
332: <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
|
+
333: <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
|
+
334: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">uri</span>)
|
617
|
+
335: <span class="ruby-keyword kw">end</span>
|
618
|
+
336: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
|
619
|
+
337: <span class="ruby-keyword kw">end</span>
|
620
620
|
</pre>
|
621
621
|
</div>
|
622
622
|
</div>
|
@@ -640,27 +640,27 @@ parts. Passing nil for any of these parameters is acceptable.
|
|
640
640
|
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
641
641
|
<div class="method-source-code" id="M000012-source">
|
642
642
|
<pre>
|
643
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
643
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 493</span>
|
644
|
+
493: <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
|
+
494: <span class="ruby-ivar">@scheme</span> = <span class="ruby-identifier">scheme</span>
|
646
|
+
495: <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
|
+
496: <span class="ruby-ivar">@user</span> = <span class="ruby-identifier">user</span>
|
648
|
+
497: <span class="ruby-ivar">@password</span> = <span class="ruby-identifier">password</span>
|
649
|
+
498: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
|
650
|
+
499: <span class="ruby-ivar">@specified_port</span> = <span class="ruby-identifier">port</span>.<span class="ruby-identifier">to_s</span>
|
651
|
+
500: <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
|
+
501: <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
|
+
502: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>,
|
654
|
+
503: <span class="ruby-node">"Invalid port number: #{@port.inspect}"</span>
|
655
|
+
504: <span class="ruby-keyword kw">end</span>
|
656
|
+
505: <span class="ruby-ivar">@port</span> = <span class="ruby-ivar">@port</span>.<span class="ruby-identifier">to_i</span>
|
657
|
+
506: <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
|
+
507: <span class="ruby-ivar">@path</span> = (<span class="ruby-identifier">path</span> <span class="ruby-operator">||</span> <span class="ruby-value str">""</span>)
|
659
|
+
508: <span class="ruby-ivar">@query</span> = <span class="ruby-identifier">query</span>
|
660
|
+
509: <span class="ruby-ivar">@fragment</span> = <span class="ruby-identifier">fragment</span>
|
661
|
+
510:
|
662
|
+
511: <span class="ruby-identifier">validate</span>()
|
663
|
+
512: <span class="ruby-keyword kw">end</span>
|
664
664
|
</pre>
|
665
665
|
</div>
|
666
666
|
</div>
|
@@ -685,43 +685,43 @@ names.
|
|
685
685
|
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
686
686
|
<div class="method-source-code" id="M000010-source">
|
687
687
|
<pre>
|
688
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
688
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 401</span>
|
689
|
+
401: <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
|
+
402: <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
|
+
403: <span class="ruby-identifier">segments</span> = {
|
692
|
+
404: <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
|
+
405: <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
|
+
406: <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
|
+
407: <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
|
+
408: <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
|
+
409: <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
|
+
410: <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
|
+
411: <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
|
+
412: }
|
701
|
+
413: <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
|
+
414: <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
|
+
415: <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
|
+
416: <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
|
+
417: <span class="ruby-keyword kw">end</span>
|
706
|
+
418: <span class="ruby-keyword kw">end</span>
|
707
|
+
419: <span class="ruby-keyword kw">end</span>
|
708
|
+
420: <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
|
+
421: <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
|
+
422: <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
|
+
423: <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
|
+
424: <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
|
+
425: <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
|
+
426: <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
|
+
427: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:host</span>],
|
716
|
+
428: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:port</span>],
|
717
|
+
429: <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
|
+
430: <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
|
+
431: <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
|
+
432: <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
|
+
433: <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
|
+
434: <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
|
+
435: ).<span class="ruby-identifier">to_s</span>
|
724
|
+
436: <span class="ruby-keyword kw">end</span>
|
725
725
|
</pre>
|
726
726
|
</div>
|
727
727
|
</div>
|
@@ -813,26 +813,26 @@ allow for better <a href="URI.html">URI</a> normalization.
|
|
813
813
|
onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
|
814
814
|
<div class="method-source-code" id="M000026-source">
|
815
815
|
<pre>
|
816
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
816
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 669</span>
|
817
|
+
669: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme_mapping</span>
|
818
|
+
670: <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
|
+
671: <span class="ruby-ivar">@protocol_mapping</span> = {
|
820
|
+
672: <span class="ruby-value str">"http"</span> =<span class="ruby-operator">></span> <span class="ruby-value">80</span>,
|
821
|
+
673: <span class="ruby-value str">"https"</span> =<span class="ruby-operator">></span> <span class="ruby-value">443</span>,
|
822
|
+
674: <span class="ruby-value str">"ftp"</span> =<span class="ruby-operator">></span> <span class="ruby-value">21</span>,
|
823
|
+
675: <span class="ruby-value str">"tftp"</span> =<span class="ruby-operator">></span> <span class="ruby-value">69</span>,
|
824
|
+
676: <span class="ruby-value str">"ssh"</span> =<span class="ruby-operator">></span> <span class="ruby-value">22</span>,
|
825
|
+
677: <span class="ruby-value str">"svn+ssh"</span> =<span class="ruby-operator">></span> <span class="ruby-value">22</span>,
|
826
|
+
678: <span class="ruby-value str">"telnet"</span> =<span class="ruby-operator">></span> <span class="ruby-value">23</span>,
|
827
|
+
679: <span class="ruby-value str">"nntp"</span> =<span class="ruby-operator">></span> <span class="ruby-value">119</span>,
|
828
|
+
680: <span class="ruby-value str">"gopher"</span> =<span class="ruby-operator">></span> <span class="ruby-value">70</span>,
|
829
|
+
681: <span class="ruby-value str">"wais"</span> =<span class="ruby-operator">></span> <span class="ruby-value">210</span>,
|
830
|
+
682: <span class="ruby-value str">"ldap"</span> =<span class="ruby-operator">></span> <span class="ruby-value">389</span>,
|
831
|
+
683: <span class="ruby-value str">"prospero"</span> =<span class="ruby-operator">></span> <span class="ruby-value">1525</span>
|
832
|
+
684: }
|
833
|
+
685: <span class="ruby-keyword kw">end</span>
|
834
|
+
686: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@protocol_mapping</span>
|
835
|
+
687: <span class="ruby-keyword kw">end</span>
|
836
836
|
</pre>
|
837
837
|
</div>
|
838
838
|
</div>
|
@@ -856,13 +856,13 @@ href="URI.html">URI</a> segment. Returns a string.
|
|
856
856
|
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
857
857
|
<div class="method-source-code" id="M000008-source">
|
858
858
|
<pre>
|
859
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
859
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 364</span>
|
860
|
+
364: <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
|
+
365: <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
|
+
366: <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
|
+
367: <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
|
+
368: <span class="ruby-keyword kw">end</span>
|
865
|
+
369: <span class="ruby-keyword kw">end</span>
|
866
866
|
</pre>
|
867
867
|
</div>
|
868
868
|
</div>
|
@@ -887,96 +887,96 @@ Joins two URIs together.
|
|
887
887
|
onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
|
888
888
|
<div class="method-source-code" id="M000041-source">
|
889
889
|
<pre>
|
890
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
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
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
890
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 788</span>
|
891
|
+
788: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span>(<span class="ruby-identifier">uri</span>)
|
892
|
+
789: <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
|
+
790: <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
|
+
791: <span class="ruby-keyword kw">end</span>
|
895
|
+
792: <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
|
+
793: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dup</span>
|
897
|
+
794: <span class="ruby-keyword kw">end</span>
|
898
|
+
795:
|
899
|
+
796: <span class="ruby-identifier">joined_scheme</span> = <span class="ruby-keyword kw">nil</span>
|
900
|
+
797: <span class="ruby-identifier">joined_user</span> = <span class="ruby-keyword kw">nil</span>
|
901
|
+
798: <span class="ruby-identifier">joined_password</span> = <span class="ruby-keyword kw">nil</span>
|
902
|
+
799: <span class="ruby-identifier">joined_host</span> = <span class="ruby-keyword kw">nil</span>
|
903
|
+
800: <span class="ruby-identifier">joined_port</span> = <span class="ruby-keyword kw">nil</span>
|
904
|
+
801: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">nil</span>
|
905
|
+
802: <span class="ruby-identifier">joined_query</span> = <span class="ruby-keyword kw">nil</span>
|
906
|
+
803: <span class="ruby-identifier">joined_fragment</span> = <span class="ruby-keyword kw">nil</span>
|
907
|
+
804:
|
908
|
+
805: <span class="ruby-comment cmt"># Section 5.2.2 of RFC 3986</span>
|
909
|
+
806: <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
|
+
807: <span class="ruby-identifier">joined_scheme</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span>
|
911
|
+
808: <span class="ruby-identifier">joined_user</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">user</span>
|
912
|
+
809: <span class="ruby-identifier">joined_password</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">password</span>
|
913
|
+
810: <span class="ruby-identifier">joined_host</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>
|
914
|
+
811: <span class="ruby-identifier">joined_port</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">specified_port</span>
|
915
|
+
812: <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
|
+
813: <span class="ruby-identifier">joined_query</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
|
917
|
+
814: <span class="ruby-keyword kw">else</span>
|
918
|
+
815: <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
|
+
816: <span class="ruby-identifier">joined_user</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">user</span>
|
920
|
+
817: <span class="ruby-identifier">joined_password</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">password</span>
|
921
|
+
818: <span class="ruby-identifier">joined_host</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>
|
922
|
+
819: <span class="ruby-identifier">joined_port</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">specified_port</span>
|
923
|
+
820: <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
|
+
821: <span class="ruby-identifier">joined_query</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
|
925
|
+
822: <span class="ruby-keyword kw">else</span>
|
926
|
+
823: <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
|
+
824: <span class="ruby-identifier">joined_path</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>
|
928
|
+
825: <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
|
+
826: <span class="ruby-identifier">joined_query</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
|
930
|
+
827: <span class="ruby-keyword kw">else</span>
|
931
|
+
828: <span class="ruby-identifier">joined_query</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>
|
932
|
+
829: <span class="ruby-keyword kw">end</span>
|
933
|
+
830: <span class="ruby-keyword kw">else</span>
|
934
|
+
831: <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
|
+
832: <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
|
+
833: <span class="ruby-keyword kw">else</span>
|
937
|
+
834: <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
|
+
835: <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
|
+
836: <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
|
+
837:
|
941
|
+
838: <span class="ruby-comment cmt"># Section 5.2.3 of RFC 3986</span>
|
942
|
+
839: <span class="ruby-comment cmt">#</span>
|
943
|
+
840: <span class="ruby-comment cmt"># Removes the right-most path segment from the base path.</span>
|
944
|
+
841: <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
|
+
842: <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
|
+
843: <span class="ruby-keyword kw">else</span>
|
947
|
+
844: <span class="ruby-identifier">base_path</span> = <span class="ruby-value str">""</span>
|
948
|
+
845: <span class="ruby-keyword kw">end</span>
|
949
|
+
846:
|
950
|
+
847: <span class="ruby-comment cmt"># If the base path is empty and an authority segment has been</span>
|
951
|
+
848: <span class="ruby-comment cmt"># defined, use a base path of "/"</span>
|
952
|
+
849: <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
|
+
850: <span class="ruby-identifier">base_path</span> = <span class="ruby-value str">"/"</span>
|
954
|
+
851: <span class="ruby-keyword kw">end</span>
|
955
|
+
852:
|
956
|
+
853: <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
|
+
854: <span class="ruby-keyword kw">end</span>
|
958
|
+
855: <span class="ruby-identifier">joined_query</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>
|
959
|
+
856: <span class="ruby-keyword kw">end</span>
|
960
|
+
857: <span class="ruby-identifier">joined_user</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span>
|
961
|
+
858: <span class="ruby-identifier">joined_password</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>
|
962
|
+
859: <span class="ruby-identifier">joined_host</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>
|
963
|
+
860: <span class="ruby-identifier">joined_port</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">specified_port</span>
|
964
|
+
861: <span class="ruby-keyword kw">end</span>
|
965
|
+
862: <span class="ruby-identifier">joined_scheme</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>
|
966
|
+
863: <span class="ruby-keyword kw">end</span>
|
967
|
+
864: <span class="ruby-identifier">joined_fragment</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">fragment</span>
|
968
|
+
865:
|
969
|
+
866: <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
|
+
867: <span class="ruby-identifier">joined_scheme</span>,
|
971
|
+
868: <span class="ruby-identifier">joined_user</span>,
|
972
|
+
869: <span class="ruby-identifier">joined_password</span>,
|
973
|
+
870: <span class="ruby-identifier">joined_host</span>,
|
974
|
+
871: <span class="ruby-identifier">joined_port</span>,
|
975
|
+
872: <span class="ruby-identifier">joined_path</span>,
|
976
|
+
873: <span class="ruby-identifier">joined_query</span>,
|
977
|
+
874: <span class="ruby-identifier">joined_fragment</span>
|
978
|
+
875: )
|
979
|
+
876: <span class="ruby-keyword kw">end</span>
|
980
980
|
</pre>
|
981
981
|
</div>
|
982
982
|
</div>
|
@@ -1000,11 +1000,11 @@ method normalizes both URIs before doing the comparison.
|
|
1000
1000
|
onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
|
1001
1001
|
<div class="method-source-code" id="M000052-source">
|
1002
1002
|
<pre>
|
1003
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1003
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1062</span>
|
1004
|
+
1062: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">uri</span>)
|
1005
|
+
1063: <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
|
+
1064: <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
|
+
1065: <span class="ruby-keyword kw">end</span>
|
1008
1008
|
</pre>
|
1009
1009
|
</div>
|
1010
1010
|
</div>
|
@@ -1029,19 +1029,19 @@ comparison against strings.
|
|
1029
1029
|
onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
|
1030
1030
|
<div class="method-source-code" id="M000051-source">
|
1031
1031
|
<pre>
|
1032
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1032
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1047</span>
|
1033
|
+
1047: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">===</span>(<span class="ruby-identifier">uri</span>)
|
1034
|
+
1048: <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
|
+
1049: <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
|
+
1050: <span class="ruby-keyword kw">else</span>
|
1037
|
+
1051: <span class="ruby-keyword kw">begin</span>
|
1038
|
+
1052: <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
|
+
1053: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">InvalidURIError</span>
|
1040
|
+
1054: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
1041
|
+
1055: <span class="ruby-keyword kw">end</span>
|
1042
|
+
1056: <span class="ruby-keyword kw">end</span>
|
1043
|
+
1057: <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
|
+
1058: <span class="ruby-keyword kw">end</span>
|
1045
1045
|
</pre>
|
1046
1046
|
</div>
|
1047
1047
|
</div>
|
@@ -1064,10 +1064,10 @@ Returns true if this <a href="URI.html">URI</a> is known to be absolute.
|
|
1064
1064
|
onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
|
1065
1065
|
<div class="method-source-code" id="M000040-source">
|
1066
1066
|
<pre>
|
1067
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1067
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 783</span>
|
1068
|
+
783: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">absolute?</span>
|
1069
|
+
784: <span class="ruby-keyword kw">return</span> <span class="ruby-operator">!</span><span class="ruby-identifier">relative?</span>
|
1070
|
+
785: <span class="ruby-keyword kw">end</span>
|
1071
1071
|
</pre>
|
1072
1072
|
</div>
|
1073
1073
|
</div>
|
@@ -1091,21 +1091,21 @@ href="URI.html">URI</a>.
|
|
1091
1091
|
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
1092
1092
|
<div class="method-source-code" id="M000023-source">
|
1093
1093
|
<pre>
|
1094
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1094
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 617</span>
|
1095
|
+
617: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">authority</span>
|
1096
|
+
618: <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
|
+
619: <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
|
+
620: <span class="ruby-ivar">@authority</span> = <span class="ruby-value str">""</span>
|
1099
|
+
621: <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
|
+
622: <span class="ruby-ivar">@authority</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{self.userinfo}@"</span>
|
1101
|
+
623: <span class="ruby-keyword kw">end</span>
|
1102
|
+
624: <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
|
+
625: <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
|
+
626: <span class="ruby-ivar">@authority</span> <span class="ruby-operator"><<</span> <span class="ruby-node">":#{self.specified_port}"</span>
|
1105
|
+
627: <span class="ruby-keyword kw">end</span>
|
1106
|
+
628: <span class="ruby-keyword kw">end</span>
|
1107
|
+
629: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@authority</span>
|
1108
|
+
630: <span class="ruby-keyword kw">end</span>
|
1109
1109
|
</pre>
|
1110
1110
|
</div>
|
1111
1111
|
</div>
|
@@ -1129,32 +1129,32 @@ href="URI.html">URI</a>.
|
|
1129
1129
|
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
1130
1130
|
<div class="method-source-code" id="M000024-source">
|
1131
1131
|
<pre>
|
1132
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1132
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 633</span>
|
1133
|
+
633: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">authority=</span>(<span class="ruby-identifier">new_authority</span>)
|
1134
|
+
634: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">new_authority</span>
|
1135
|
+
635: <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
|
+
636: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">new_userinfo</span>
|
1137
|
+
637: <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
|
+
638: <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
|
+
639: <span class="ruby-keyword kw">end</span>
|
1140
|
+
640: <span class="ruby-identifier">new_host</span> =
|
1141
|
+
641: <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
|
+
642: <span class="ruby-identifier">new_port</span> =
|
1143
|
+
643: <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
|
+
644: <span class="ruby-keyword kw">end</span>
|
1145
|
+
645:
|
1146
|
+
646: <span class="ruby-comment cmt"># Password assigned first to ensure validity in case of nil</span>
|
1147
|
+
647: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span> = <span class="ruby-identifier">new_password</span>
|
1148
|
+
648: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span> = <span class="ruby-identifier">new_user</span>
|
1149
|
+
649: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span> = <span class="ruby-identifier">new_host</span>
|
1150
|
+
650:
|
1151
|
+
651: <span class="ruby-comment cmt"># Port reset to allow port normalization</span>
|
1152
|
+
652: <span class="ruby-ivar">@port</span> = <span class="ruby-keyword kw">nil</span>
|
1153
|
+
653: <span class="ruby-ivar">@specified_port</span> = <span class="ruby-identifier">new_port</span>
|
1154
|
+
654:
|
1155
|
+
655: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
|
1156
|
+
656: <span class="ruby-identifier">validate</span>()
|
1157
|
+
657: <span class="ruby-keyword kw">end</span>
|
1158
1158
|
</pre>
|
1159
1159
|
</div>
|
1160
1160
|
</div>
|
@@ -1179,11 +1179,11 @@ there is no <a href="URI.html#M000030">path</a> component.
|
|
1179
1179
|
onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
|
1180
1180
|
<div class="method-source-code" id="M000032-source">
|
1181
1181
|
<pre>
|
1182
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1182
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 735</span>
|
1183
|
+
735: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">basename</span>
|
1184
|
+
736: <span class="ruby-comment cmt"># Path cannot be nil</span>
|
1185
|
+
737: <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
|
+
738: <span class="ruby-keyword kw">end</span>
|
1187
1187
|
</pre>
|
1188
1188
|
</div>
|
1189
1189
|
</div>
|
@@ -1209,17 +1209,17 @@ more information.
|
|
1209
1209
|
onclick="toggleCode('M000050-source');return false;">[Source]</a></p>
|
1210
1210
|
<div class="method-source-code" id="M000050-source">
|
1211
1211
|
<pre>
|
1212
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1212
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1033</span>
|
1213
|
+
1033: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">display_uri</span>
|
1214
|
+
1034: <span class="ruby-identifier">display_uri</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalize</span>
|
1215
|
+
1035: <span class="ruby-keyword kw">begin</span>
|
1216
|
+
1036: <span class="ruby-identifier">display_uri</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-value str">"@host"</span>,
|
1217
|
+
1037: <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
|
+
1038: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
|
1219
|
+
1039: <span class="ruby-keyword kw">nil</span>
|
1220
|
+
1040: <span class="ruby-keyword kw">end</span>
|
1221
|
+
1041: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">display_uri</span>
|
1222
|
+
1042: <span class="ruby-keyword kw">end</span>
|
1223
1223
|
</pre>
|
1224
1224
|
</div>
|
1225
1225
|
</div>
|
@@ -1242,28 +1242,28 @@ Clones the <a href="URI.html">URI</a> object.
|
|
1242
1242
|
onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
|
1243
1243
|
<div class="method-source-code" id="M000054-source">
|
1244
1244
|
<pre>
|
1245
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1245
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1075</span>
|
1246
|
+
1075: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dup</span>
|
1247
|
+
1076: <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
|
+
1077: <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
|
+
1078: <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
|
+
1079: <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
|
+
1080: <span class="ruby-identifier">duplicated_port</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">specified_port</span>
|
1252
|
+
1081: <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
|
+
1082: <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
|
+
1083: <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
|
+
1084: <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
|
+
1085: <span class="ruby-identifier">duplicated_scheme</span>,
|
1257
|
+
1086: <span class="ruby-identifier">duplicated_user</span>,
|
1258
|
+
1087: <span class="ruby-identifier">duplicated_password</span>,
|
1259
|
+
1088: <span class="ruby-identifier">duplicated_host</span>,
|
1260
|
+
1089: <span class="ruby-identifier">duplicated_port</span>,
|
1261
|
+
1090: <span class="ruby-identifier">duplicated_path</span>,
|
1262
|
+
1091: <span class="ruby-identifier">duplicated_query</span>,
|
1263
|
+
1092: <span class="ruby-identifier">duplicated_fragment</span>
|
1264
|
+
1093: )
|
1265
|
+
1094: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">duplicated_uri</span>
|
1266
|
+
1095: <span class="ruby-keyword kw">end</span>
|
1267
1267
|
</pre>
|
1268
1268
|
</div>
|
1269
1269
|
</div>
|
@@ -1288,11 +1288,11 @@ href="URI.html">URI</a> before doing the comparison.
|
|
1288
1288
|
onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
|
1289
1289
|
<div class="method-source-code" id="M000053-source">
|
1290
1290
|
<pre>
|
1291
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1291
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1069</span>
|
1292
|
+
1069: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">eql?</span>(<span class="ruby-identifier">uri</span>)
|
1293
|
+
1070: <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
|
+
1071: <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
|
+
1072: <span class="ruby-keyword kw">end</span>
|
1296
1296
|
</pre>
|
1297
1297
|
</div>
|
1298
1298
|
</div>
|
@@ -1318,11 +1318,11 @@ href="URI.html#M000030">path</a> component.
|
|
1318
1318
|
onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
|
1319
1319
|
<div class="method-source-code" id="M000033-source">
|
1320
1320
|
<pre>
|
1321
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1321
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 743</span>
|
1322
|
+
743: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">extname</span>
|
1323
|
+
744: <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
|
+
745: <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
|
+
746: <span class="ruby-keyword kw">end</span>
|
1326
1326
|
</pre>
|
1327
1327
|
</div>
|
1328
1328
|
</div>
|
@@ -1390,45 +1390,61 @@ An example:
|
|
1390
1390
|
268: <span class="ruby-identifier">mapping</span> = {}
|
1391
1391
|
269: <span class="ruby-identifier">variable_regexp</span> =
|
1392
1392
|
270: <span class="ruby-node">/\{([#{Addressable::URI::CharacterClasses::UNRESERVED}]+)\}/</span>
|
1393
|
-
271:
|
1394
|
-
272: <span class="ruby-
|
1395
|
-
273: <span class="ruby-identifier">
|
1396
|
-
274:
|
1397
|
-
275: <span class="ruby-
|
1398
|
-
276:
|
1399
|
-
277:
|
1400
|
-
278:
|
1401
|
-
279:
|
1402
|
-
280:
|
1403
|
-
281:
|
1404
|
-
282:
|
1405
|
-
283:
|
1406
|
-
284:
|
1407
|
-
285: <span class="ruby-identifier">capture_group</span>
|
1408
|
-
286:
|
1409
|
-
287:
|
1410
|
-
288:
|
1411
|
-
289:
|
1412
|
-
290:
|
1413
|
-
291: <span class="ruby-
|
1414
|
-
292:
|
1415
|
-
293:
|
1416
|
-
294:
|
1417
|
-
295:
|
1418
|
-
296:
|
1419
|
-
297:
|
1420
|
-
298:
|
1421
|
-
299:
|
1422
|
-
300:
|
1423
|
-
301:
|
1424
|
-
302:
|
1425
|
-
303: <span class="ruby-keyword kw">
|
1426
|
-
304: <span class="ruby-
|
1427
|
-
305:
|
1428
|
-
306:
|
1429
|
-
307:
|
1430
|
-
308:
|
1431
|
-
309:
|
1393
|
+
271:
|
1394
|
+
272: <span class="ruby-comment cmt"># Get all the variables in the pattern</span>
|
1395
|
+
273: <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>
|
1396
|
+
274:
|
1397
|
+
275: <span class="ruby-comment cmt"># Initialize all result values to the empty string</span>
|
1398
|
+
276: <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> }
|
1399
|
+
277:
|
1400
|
+
278: <span class="ruby-comment cmt"># Escape the pattern</span>
|
1401
|
+
279: <span class="ruby-identifier">escaped_pattern</span> =
|
1402
|
+
280: <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>)
|
1403
|
+
281:
|
1404
|
+
282: <span class="ruby-comment cmt"># Create a regular expression that captures the values of the</span>
|
1405
|
+
283: <span class="ruby-comment cmt"># variables in the URI.</span>
|
1406
|
+
284: <span class="ruby-identifier">regexp_string</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>
|
1407
|
+
285: <span class="ruby-identifier">capture_group</span> = <span class="ruby-value str">"(.*)"</span>
|
1408
|
+
286:
|
1409
|
+
287: <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>
|
1410
|
+
288: <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>)
|
1411
|
+
289: <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>]
|
1412
|
+
290: <span class="ruby-identifier">capture_group</span> = <span class="ruby-node">"(#{processor.match(name)})"</span>
|
1413
|
+
291: <span class="ruby-keyword kw">end</span>
|
1414
|
+
292: <span class="ruby-keyword kw">end</span>
|
1415
|
+
293:
|
1416
|
+
294: <span class="ruby-identifier">capture_group</span>
|
1417
|
+
295: <span class="ruby-keyword kw">end</span>
|
1418
|
+
296:
|
1419
|
+
297: <span class="ruby-comment cmt"># Ensure that the regular expression matches the whole URI.</span>
|
1420
|
+
298: <span class="ruby-identifier">regexp_string</span> = <span class="ruby-node">"^#{regexp_string}$"</span>
|
1421
|
+
299:
|
1422
|
+
300: <span class="ruby-identifier">regexp</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">regexp_string</span>)
|
1423
|
+
301: <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>
|
1424
|
+
302:
|
1425
|
+
303: <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> <span class="ruby-operator">&&</span> <span class="ruby-identifier">variables</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
1426
|
+
304: <span class="ruby-comment cmt"># We have a match.</span>
|
1427
|
+
305: <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>
|
1428
|
+
306: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">variables</span>[<span class="ruby-identifier">i</span>]
|
1429
|
+
307: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">values</span>[<span class="ruby-identifier">i</span>]
|
1430
|
+
308:
|
1431
|
+
309: <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>
|
1432
|
+
310: <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>)
|
1433
|
+
311: <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>)
|
1434
|
+
312: <span class="ruby-keyword kw">end</span>
|
1435
|
+
313: <span class="ruby-keyword kw">end</span>
|
1436
|
+
314:
|
1437
|
+
315: <span class="ruby-identifier">mapping</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">value</span>
|
1438
|
+
316: <span class="ruby-keyword kw">end</span>
|
1439
|
+
317: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">mapping</span>
|
1440
|
+
318: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">pattern</span>
|
1441
|
+
319: <span class="ruby-comment cmt"># The pattern contained no variables but still matched.</span>
|
1442
|
+
320: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">mapping</span>
|
1443
|
+
321: <span class="ruby-keyword kw">else</span>
|
1444
|
+
322: <span class="ruby-comment cmt"># Pattern failed to match URI.</span>
|
1445
|
+
323: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
|
1446
|
+
324: <span class="ruby-keyword kw">end</span>
|
1447
|
+
325: <span class="ruby-keyword kw">end</span>
|
1432
1448
|
</pre>
|
1433
1449
|
</div>
|
1434
1450
|
</div>
|
@@ -1452,10 +1468,10 @@ href="URI.html">URI</a>.
|
|
1452
1468
|
onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
|
1453
1469
|
<div class="method-source-code" id="M000036-source">
|
1454
1470
|
<pre>
|
1455
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1471
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 759</span>
|
1472
|
+
759: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fragment</span>
|
1473
|
+
760: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@fragment</span>
|
1474
|
+
761: <span class="ruby-keyword kw">end</span>
|
1459
1475
|
</pre>
|
1460
1476
|
</div>
|
1461
1477
|
</div>
|
@@ -1479,10 +1495,10 @@ href="URI.html">URI</a>.
|
|
1479
1495
|
onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
|
1480
1496
|
<div class="method-source-code" id="M000037-source">
|
1481
1497
|
<pre>
|
1482
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1498
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 764</span>
|
1499
|
+
764: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fragment=</span>(<span class="ruby-identifier">new_fragment</span>)
|
1500
|
+
765: <span class="ruby-ivar">@fragment</span> = <span class="ruby-identifier">new_fragment</span>
|
1501
|
+
766: <span class="ruby-keyword kw">end</span>
|
1486
1502
|
</pre>
|
1487
1503
|
</div>
|
1488
1504
|
</div>
|
@@ -1506,10 +1522,10 @@ href="URI.html">URI</a>.
|
|
1506
1522
|
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
1507
1523
|
<div class="method-source-code" id="M000021-source">
|
1508
1524
|
<pre>
|
1509
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1525
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 601</span>
|
1526
|
+
601: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">host</span>
|
1527
|
+
602: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@host</span>
|
1528
|
+
603: <span class="ruby-keyword kw">end</span>
|
1513
1529
|
</pre>
|
1514
1530
|
</div>
|
1515
1531
|
</div>
|
@@ -1533,16 +1549,16 @@ href="URI.html">URI</a>.
|
|
1533
1549
|
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
1534
1550
|
<div class="method-source-code" id="M000022-source">
|
1535
1551
|
<pre>
|
1536
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1552
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 606</span>
|
1553
|
+
606: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">host=</span>(<span class="ruby-identifier">new_host</span>)
|
1554
|
+
607: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">new_host</span>
|
1555
|
+
608:
|
1556
|
+
609: <span class="ruby-comment cmt"># Reset dependant values</span>
|
1557
|
+
610: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
|
1558
|
+
611:
|
1559
|
+
612: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
|
1560
|
+
613: <span class="ruby-identifier">validate</span>()
|
1561
|
+
614: <span class="ruby-keyword kw">end</span>
|
1546
1562
|
</pre>
|
1547
1563
|
</div>
|
1548
1564
|
</div>
|
@@ -1566,10 +1582,10 @@ object‘s state.
|
|
1566
1582
|
onclick="toggleCode('M000057-source');return false;">[Source]</a></p>
|
1567
1583
|
<div class="method-source-code" id="M000057-source">
|
1568
1584
|
<pre>
|
1569
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1585
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1123</span>
|
1586
|
+
1123: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inspect</span>
|
1587
|
+
1124: <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>)
|
1588
|
+
1125: <span class="ruby-keyword kw">end</span>
|
1573
1589
|
</pre>
|
1574
1590
|
</div>
|
1575
1591
|
</div>
|
@@ -1592,14 +1608,14 @@ Returns true if the <a href="URI.html">URI</a> uses an IP-based protocol.
|
|
1592
1608
|
onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
|
1593
1609
|
<div class="method-source-code" id="M000038-source">
|
1594
1610
|
<pre>
|
1595
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1611
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 769</span>
|
1612
|
+
769: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ip_based?</span>
|
1613
|
+
770: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>
|
1614
|
+
771: <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>(
|
1615
|
+
772: <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>)
|
1616
|
+
773: <span class="ruby-keyword kw">end</span>
|
1617
|
+
774: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
1618
|
+
775: <span class="ruby-keyword kw">end</span>
|
1603
1619
|
</pre>
|
1604
1620
|
</div>
|
1605
1621
|
</div>
|
@@ -1650,10 +1666,10 @@ Merges two URIs together.
|
|
1650
1666
|
onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
|
1651
1667
|
<div class="method-source-code" id="M000042-source">
|
1652
1668
|
<pre>
|
1653
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1669
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 879</span>
|
1670
|
+
879: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">uri</span>)
|
1671
|
+
880: <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>
|
1672
|
+
881: <span class="ruby-keyword kw">end</span>
|
1657
1673
|
</pre>
|
1658
1674
|
</div>
|
1659
1675
|
</div>
|
@@ -1676,10 +1692,10 @@ Destructive form of <a href="URI.html#M000042">merge</a>.
|
|
1676
1692
|
onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
|
1677
1693
|
<div class="method-source-code" id="M000044-source">
|
1678
1694
|
<pre>
|
1679
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1695
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 885</span>
|
1696
|
+
885: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">uri</span>)
|
1697
|
+
886: <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>))
|
1698
|
+
887: <span class="ruby-keyword kw">end</span>
|
1683
1699
|
</pre>
|
1684
1700
|
</div>
|
1685
1701
|
</div>
|
@@ -1709,75 +1725,75 @@ multiple times.
|
|
1709
1725
|
onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
|
1710
1726
|
<div class="method-source-code" id="M000048-source">
|
1711
1727
|
<pre>
|
1712
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
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
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1728
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 956</span>
|
1729
|
+
956: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">normalize</span>
|
1730
|
+
957: <span class="ruby-identifier">normalized_scheme</span> = <span class="ruby-keyword kw">nil</span>
|
1731
|
+
958: <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>
|
1732
|
+
959: <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>
|
1733
|
+
960: <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>
|
1734
|
+
961: <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>
|
1735
|
+
962: <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>(
|
1736
|
+
963: <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>
|
1737
|
+
964: <span class="ruby-keyword kw">end</span>
|
1738
|
+
965: <span class="ruby-keyword kw">end</span>
|
1739
|
+
966: <span class="ruby-identifier">normalized_user</span> = <span class="ruby-keyword kw">nil</span>
|
1740
|
+
967: <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>
|
1741
|
+
968: <span class="ruby-identifier">normalized_password</span> = <span class="ruby-keyword kw">nil</span>
|
1742
|
+
969: <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>
|
1743
|
+
970:
|
1744
|
+
971: <span class="ruby-comment cmt"># If we are using http or https and user/password are blank,</span>
|
1745
|
+
972: <span class="ruby-comment cmt"># then we remove them</span>
|
1746
|
+
973: <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>
|
1747
|
+
974: (<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>)
|
1748
|
+
975: <span class="ruby-identifier">normalized_user</span> = <span class="ruby-keyword kw">nil</span>
|
1749
|
+
976: <span class="ruby-identifier">normalized_password</span> = <span class="ruby-keyword kw">nil</span>
|
1750
|
+
977: <span class="ruby-keyword kw">end</span>
|
1751
|
+
978:
|
1752
|
+
979: <span class="ruby-identifier">normalized_host</span> = <span class="ruby-keyword kw">nil</span>
|
1753
|
+
980: <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>
|
1754
|
+
981: <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>
|
1755
|
+
982: <span class="ruby-keyword kw">begin</span>
|
1756
|
+
983: <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>)
|
1757
|
+
984: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
|
1758
|
+
985: <span class="ruby-keyword kw">nil</span>
|
1759
|
+
986: <span class="ruby-keyword kw">end</span>
|
1760
|
+
987: <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>
|
1761
|
+
988: <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>]
|
1762
|
+
989: <span class="ruby-keyword kw">end</span>
|
1763
|
+
990: <span class="ruby-keyword kw">end</span>
|
1764
|
+
991:
|
1765
|
+
992: <span class="ruby-identifier">normalized_port</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">port</span>
|
1766
|
+
993: <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>
|
1767
|
+
994: <span class="ruby-identifier">normalized_port</span> = <span class="ruby-keyword kw">nil</span>
|
1768
|
+
995: <span class="ruby-keyword kw">end</span>
|
1769
|
+
996: <span class="ruby-identifier">normalized_path</span> = <span class="ruby-keyword kw">nil</span>
|
1770
|
+
997: <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>
|
1771
|
+
998: <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>
|
1772
|
+
999: <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>)
|
1773
|
+
1000: <span class="ruby-keyword kw">end</span>
|
1774
|
+
1001: <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>
|
1775
|
+
1002: <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>)
|
1776
|
+
1003: <span class="ruby-identifier">normalized_path</span> = <span class="ruby-value str">"/"</span>
|
1777
|
+
1004: <span class="ruby-keyword kw">end</span>
|
1778
|
+
1005: <span class="ruby-keyword kw">end</span>
|
1779
|
+
1006:
|
1780
|
+
1007: <span class="ruby-identifier">normalized_query</span> = <span class="ruby-keyword kw">nil</span>
|
1781
|
+
1008: <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>
|
1782
|
+
1009:
|
1783
|
+
1010: <span class="ruby-identifier">normalized_fragment</span> = <span class="ruby-keyword kw">nil</span>
|
1784
|
+
1011: <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>
|
1785
|
+
1012: <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>(
|
1786
|
+
1013: <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>(
|
1787
|
+
1014: <span class="ruby-identifier">normalized_scheme</span>,
|
1788
|
+
1015: <span class="ruby-identifier">normalized_user</span>,
|
1789
|
+
1016: <span class="ruby-identifier">normalized_password</span>,
|
1790
|
+
1017: <span class="ruby-identifier">normalized_host</span>,
|
1791
|
+
1018: <span class="ruby-identifier">normalized_port</span>,
|
1792
|
+
1019: <span class="ruby-identifier">normalized_path</span>,
|
1793
|
+
1020: <span class="ruby-identifier">normalized_query</span>,
|
1794
|
+
1021: <span class="ruby-identifier">normalized_fragment</span>
|
1795
|
+
1022: )))
|
1796
|
+
1023: <span class="ruby-keyword kw">end</span>
|
1781
1797
|
</pre>
|
1782
1798
|
</div>
|
1783
1799
|
</div>
|
@@ -1800,10 +1816,10 @@ Destructively normalizes this <a href="URI.html">URI</a> object.
|
|
1800
1816
|
onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
|
1801
1817
|
<div class="method-source-code" id="M000049-source">
|
1802
1818
|
<pre>
|
1803
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1819
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1026</span>
|
1820
|
+
1026: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">normalize!</span>
|
1821
|
+
1027: <span class="ruby-identifier">replace_self</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalize</span>)
|
1822
|
+
1028: <span class="ruby-keyword kw">end</span>
|
1807
1823
|
</pre>
|
1808
1824
|
</div>
|
1809
1825
|
</div>
|
@@ -1827,10 +1843,10 @@ href="URI.html">URI</a>.
|
|
1827
1843
|
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
1828
1844
|
<div class="method-source-code" id="M000017-source">
|
1829
1845
|
<pre>
|
1830
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1846
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 547</span>
|
1847
|
+
547: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">password</span>
|
1848
|
+
548: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@password</span>
|
1849
|
+
549: <span class="ruby-keyword kw">end</span>
|
1834
1850
|
</pre>
|
1835
1851
|
</div>
|
1836
1852
|
</div>
|
@@ -1854,22 +1870,22 @@ href="URI.html">URI</a>.
|
|
1854
1870
|
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
1855
1871
|
<div class="method-source-code" id="M000018-source">
|
1856
1872
|
<pre>
|
1857
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 552</span>
|
1874
|
+
552: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">password=</span>(<span class="ruby-identifier">new_password</span>)
|
1875
|
+
553: <span class="ruby-ivar">@password</span> = <span class="ruby-identifier">new_password</span>
|
1876
|
+
554:
|
1877
|
+
555: <span class="ruby-comment cmt"># You can't have a nil user with a non-nil password</span>
|
1878
|
+
556: <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>
|
1879
|
+
557: <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>
|
1880
|
+
558: <span class="ruby-keyword kw">end</span>
|
1881
|
+
559:
|
1882
|
+
560: <span class="ruby-comment cmt"># Reset dependant values</span>
|
1883
|
+
561: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-keyword kw">nil</span>
|
1884
|
+
562: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
|
1885
|
+
563:
|
1886
|
+
564: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
|
1887
|
+
565: <span class="ruby-identifier">validate</span>()
|
1888
|
+
566: <span class="ruby-keyword kw">end</span>
|
1873
1889
|
</pre>
|
1874
1890
|
</div>
|
1875
1891
|
</div>
|
@@ -1893,10 +1909,10 @@ href="URI.html">URI</a>.
|
|
1893
1909
|
onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
|
1894
1910
|
<div class="method-source-code" id="M000030-source">
|
1895
1911
|
<pre>
|
1896
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1912
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 724</span>
|
1913
|
+
724: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">path</span>
|
1914
|
+
725: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@path</span>
|
1915
|
+
726: <span class="ruby-keyword kw">end</span>
|
1900
1916
|
</pre>
|
1901
1917
|
</div>
|
1902
1918
|
</div>
|
@@ -1920,10 +1936,10 @@ href="URI.html">URI</a>.
|
|
1920
1936
|
onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
|
1921
1937
|
<div class="method-source-code" id="M000031-source">
|
1922
1938
|
<pre>
|
1923
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1939
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 729</span>
|
1940
|
+
729: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">path=</span>(<span class="ruby-identifier">new_path</span>)
|
1941
|
+
730: <span class="ruby-ivar">@path</span> = (<span class="ruby-identifier">new_path</span> <span class="ruby-operator">||</span> <span class="ruby-value str">""</span>)
|
1942
|
+
731: <span class="ruby-keyword kw">end</span>
|
1927
1943
|
</pre>
|
1928
1944
|
</div>
|
1929
1945
|
</div>
|
@@ -1952,20 +1968,20 @@ href="URI.html">URI</a>.
|
|
1952
1968
|
onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
|
1953
1969
|
<div class="method-source-code" id="M000027-source">
|
1954
1970
|
<pre>
|
1955
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1971
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 692</span>
|
1972
|
+
692: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">port</span>
|
1973
|
+
693: <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>
|
1974
|
+
694: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>
|
1975
|
+
695: <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>]
|
1976
|
+
696: <span class="ruby-keyword kw">else</span>
|
1977
|
+
697: <span class="ruby-ivar">@port</span> = <span class="ruby-keyword kw">nil</span>
|
1978
|
+
698: <span class="ruby-keyword kw">end</span>
|
1979
|
+
699: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@port</span>
|
1980
|
+
700: <span class="ruby-keyword kw">else</span>
|
1981
|
+
701: <span class="ruby-ivar">@port</span> = <span class="ruby-ivar">@port</span>.<span class="ruby-identifier">to_i</span>
|
1982
|
+
702: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@port</span>
|
1983
|
+
703: <span class="ruby-keyword kw">end</span>
|
1984
|
+
704: <span class="ruby-keyword kw">end</span>
|
1969
1985
|
</pre>
|
1970
1986
|
</div>
|
1971
1987
|
</div>
|
@@ -1989,12 +2005,12 @@ href="URI.html">URI</a>.
|
|
1989
2005
|
onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
|
1990
2006
|
<div class="method-source-code" id="M000028-source">
|
1991
2007
|
<pre>
|
1992
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
2008
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 707</span>
|
2009
|
+
707: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">port=</span>(<span class="ruby-identifier">new_port</span>)
|
2010
|
+
708: <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>
|
2011
|
+
709: <span class="ruby-ivar">@specified_port</span> = <span class="ruby-ivar">@port</span>
|
2012
|
+
710: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
|
2013
|
+
711: <span class="ruby-keyword kw">end</span>
|
1998
2014
|
</pre>
|
1999
2015
|
</div>
|
2000
2016
|
</div>
|
@@ -2018,10 +2034,10 @@ href="URI.html">URI</a>.
|
|
2018
2034
|
onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
|
2019
2035
|
<div class="method-source-code" id="M000034-source">
|
2020
2036
|
<pre>
|
2021
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2037
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 749</span>
|
2038
|
+
749: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">query</span>
|
2039
|
+
750: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@query</span>
|
2040
|
+
751: <span class="ruby-keyword kw">end</span>
|
2025
2041
|
</pre>
|
2026
2042
|
</div>
|
2027
2043
|
</div>
|
@@ -2045,10 +2061,10 @@ href="URI.html">URI</a>.
|
|
2045
2061
|
onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
|
2046
2062
|
<div class="method-source-code" id="M000035-source">
|
2047
2063
|
<pre>
|
2048
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2064
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 754</span>
|
2065
|
+
754: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">query=</span>(<span class="ruby-identifier">new_query</span>)
|
2066
|
+
755: <span class="ruby-ivar">@query</span> = <span class="ruby-identifier">new_query</span>
|
2067
|
+
756: <span class="ruby-keyword kw">end</span>
|
2052
2068
|
</pre>
|
2053
2069
|
</div>
|
2054
2070
|
</div>
|
@@ -2071,10 +2087,10 @@ Returns true if this <a href="URI.html">URI</a> is known to be relative.
|
|
2071
2087
|
onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
|
2072
2088
|
<div class="method-source-code" id="M000039-source">
|
2073
2089
|
<pre>
|
2074
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2090
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 778</span>
|
2091
|
+
778: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">relative?</span>
|
2092
|
+
779: <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>
|
2093
|
+
780: <span class="ruby-keyword kw">end</span>
|
2078
2094
|
</pre>
|
2079
2095
|
</div>
|
2080
2096
|
</div>
|
@@ -2100,55 +2116,55 @@ necessary.
|
|
2100
2116
|
onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
|
2101
2117
|
<div class="method-source-code" id="M000046-source">
|
2102
2118
|
<pre>
|
2103
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2151
|
-
|
2119
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 893</span>
|
2120
|
+
893: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">route_from</span>(<span class="ruby-identifier">uri</span>)
|
2121
|
+
894: <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>
|
2122
|
+
895: <span class="ruby-identifier">normalized_self</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">normalize</span>
|
2123
|
+
896: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">relative?</span>
|
2124
|
+
897: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"Expected absolute URI, got: #{self.to_s}"</span>
|
2125
|
+
898: <span class="ruby-keyword kw">end</span>
|
2126
|
+
899: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">relative?</span>
|
2127
|
+
900: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"Expected absolute URI, got: #{uri.to_s}"</span>
|
2128
|
+
901: <span class="ruby-keyword kw">end</span>
|
2129
|
+
902: <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>
|
2130
|
+
903: <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>)
|
2131
|
+
904: <span class="ruby-keyword kw">end</span>
|
2132
|
+
905: <span class="ruby-identifier">segments</span> = <span class="ruby-identifier">normalized_self</span>.<span class="ruby-identifier">to_hash</span>
|
2133
|
+
906: <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>
|
2134
|
+
907: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>] = <span class="ruby-keyword kw">nil</span>
|
2135
|
+
908: <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>
|
2136
|
+
909: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:user</span>] = <span class="ruby-keyword kw">nil</span>
|
2137
|
+
910: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:password</span>] = <span class="ruby-keyword kw">nil</span>
|
2138
|
+
911: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:host</span>] = <span class="ruby-keyword kw">nil</span>
|
2139
|
+
912: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:port</span>] = <span class="ruby-keyword kw">nil</span>
|
2140
|
+
913: <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>
|
2141
|
+
914: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:path</span>] = <span class="ruby-keyword kw">nil</span>
|
2142
|
+
915: <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>
|
2143
|
+
916: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:query</span>] = <span class="ruby-keyword kw">nil</span>
|
2144
|
+
917: <span class="ruby-keyword kw">end</span>
|
2145
|
+
918: <span class="ruby-keyword kw">else</span>
|
2146
|
+
919: <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>
|
2147
|
+
920: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:path</span>].<span class="ruby-identifier">gsub!</span>(
|
2148
|
+
921: <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>)
|
2149
|
+
922: <span class="ruby-keyword kw">end</span>
|
2150
|
+
923: <span class="ruby-keyword kw">end</span>
|
2151
|
+
924: <span class="ruby-keyword kw">end</span>
|
2152
|
+
925: <span class="ruby-keyword kw">end</span>
|
2153
|
+
926: <span class="ruby-comment cmt"># Avoid network-path references.</span>
|
2154
|
+
927: <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>
|
2155
|
+
928: <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>
|
2156
|
+
929: <span class="ruby-keyword kw">end</span>
|
2157
|
+
930: <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>(
|
2158
|
+
931: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:scheme</span>],
|
2159
|
+
932: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:user</span>],
|
2160
|
+
933: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:password</span>],
|
2161
|
+
934: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:host</span>],
|
2162
|
+
935: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:port</span>],
|
2163
|
+
936: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:path</span>],
|
2164
|
+
937: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:query</span>],
|
2165
|
+
938: <span class="ruby-identifier">segments</span>[<span class="ruby-identifier">:fragment</span>]
|
2166
|
+
939: )
|
2167
|
+
940: <span class="ruby-keyword kw">end</span>
|
2152
2168
|
</pre>
|
2153
2169
|
</div>
|
2154
2170
|
</div>
|
@@ -2174,10 +2190,10 @@ necessary.
|
|
2174
2190
|
onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
|
2175
2191
|
<div class="method-source-code" id="M000047-source">
|
2176
2192
|
<pre>
|
2177
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2193
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 945</span>
|
2194
|
+
945: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">route_to</span>(<span class="ruby-identifier">uri</span>)
|
2195
|
+
946: <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>)
|
2196
|
+
947: <span class="ruby-keyword kw">end</span>
|
2181
2197
|
</pre>
|
2182
2198
|
</div>
|
2183
2199
|
</div>
|
@@ -2201,10 +2217,10 @@ href="URI.html">URI</a>.
|
|
2201
2217
|
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
2202
2218
|
<div class="method-source-code" id="M000013-source">
|
2203
2219
|
<pre>
|
2204
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2220
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 515</span>
|
2221
|
+
515: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">scheme</span>
|
2222
|
+
516: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@scheme</span>
|
2223
|
+
517: <span class="ruby-keyword kw">end</span>
|
2208
2224
|
</pre>
|
2209
2225
|
</div>
|
2210
2226
|
</div>
|
@@ -2228,10 +2244,10 @@ href="URI.html">URI</a>.)
|
|
2228
2244
|
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
2229
2245
|
<div class="method-source-code" id="M000014-source">
|
2230
2246
|
<pre>
|
2231
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2247
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 520</span>
|
2248
|
+
520: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">scheme=</span>(<span class="ruby-identifier">new_scheme</span>)
|
2249
|
+
521: <span class="ruby-ivar">@scheme</span> = <span class="ruby-identifier">new_scheme</span>
|
2250
|
+
522: <span class="ruby-keyword kw">end</span>
|
2235
2251
|
</pre>
|
2236
2252
|
</div>
|
2237
2253
|
</div>
|
@@ -2255,15 +2271,15 @@ specified in the <a href="URI.html">URI</a> string.
|
|
2255
2271
|
onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
|
2256
2272
|
<div class="method-source-code" id="M000029-source">
|
2257
2273
|
<pre>
|
2258
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2264
|
-
|
2265
|
-
|
2266
|
-
|
2274
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 714</span>
|
2275
|
+
714: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">specified_port</span>
|
2276
|
+
715: <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>
|
2277
|
+
716: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">port</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
2278
|
+
717: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
|
2279
|
+
718: <span class="ruby-keyword kw">else</span>
|
2280
|
+
719: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">port</span>
|
2281
|
+
720: <span class="ruby-keyword kw">end</span>
|
2282
|
+
721: <span class="ruby-keyword kw">end</span>
|
2267
2283
|
</pre>
|
2268
2284
|
</div>
|
2269
2285
|
</div>
|
@@ -2286,19 +2302,19 @@ Returns a Hash of the <a href="URI.html">URI</a> segments.
|
|
2286
2302
|
onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
|
2287
2303
|
<div class="method-source-code" id="M000056-source">
|
2288
2304
|
<pre>
|
2289
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2290
|
-
|
2291
|
-
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
|
2305
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1109</span>
|
2306
|
+
1109: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_hash</span>
|
2307
|
+
1110: <span class="ruby-keyword kw">return</span> {
|
2308
|
+
1111: <span class="ruby-identifier">:scheme</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scheme</span>,
|
2309
|
+
1112: <span class="ruby-identifier">:user</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span>,
|
2310
|
+
1113: <span class="ruby-identifier">:password</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>,
|
2311
|
+
1114: <span class="ruby-identifier">:host</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">host</span>,
|
2312
|
+
1115: <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>,
|
2313
|
+
1116: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">path</span>,
|
2314
|
+
1117: <span class="ruby-identifier">:query</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">query</span>,
|
2315
|
+
1118: <span class="ruby-identifier">:fragment</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">fragment</span>
|
2316
|
+
1119: }
|
2317
|
+
1120: <span class="ruby-keyword kw">end</span>
|
2302
2318
|
</pre>
|
2303
2319
|
</div>
|
2304
2320
|
</div>
|
@@ -2321,16 +2337,16 @@ Returns the assembled <a href="URI.html">URI</a> as a string.
|
|
2321
2337
|
onclick="toggleCode('M000055-source');return false;">[Source]</a></p>
|
2322
2338
|
<div class="method-source-code" id="M000055-source">
|
2323
2339
|
<pre>
|
2324
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2329
|
-
|
2330
|
-
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2340
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 1098</span>
|
2341
|
+
1098: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
2342
|
+
1099: <span class="ruby-identifier">uri_string</span> = <span class="ruby-value str">""</span>
|
2343
|
+
1100: <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>
|
2344
|
+
1101: <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>
|
2345
|
+
1102: <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>
|
2346
|
+
1103: <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>
|
2347
|
+
1104: <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>
|
2348
|
+
1105: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">uri_string</span>
|
2349
|
+
1106: <span class="ruby-keyword kw">end</span>
|
2334
2350
|
</pre>
|
2335
2351
|
</div>
|
2336
2352
|
</div>
|
@@ -2354,10 +2370,10 @@ href="URI.html">URI</a>.
|
|
2354
2370
|
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
2355
2371
|
<div class="method-source-code" id="M000015-source">
|
2356
2372
|
<pre>
|
2357
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2358
|
-
|
2359
|
-
|
2360
|
-
|
2373
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 525</span>
|
2374
|
+
525: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">user</span>
|
2375
|
+
526: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@user</span>
|
2376
|
+
527: <span class="ruby-keyword kw">end</span>
|
2361
2377
|
</pre>
|
2362
2378
|
</div>
|
2363
2379
|
</div>
|
@@ -2381,22 +2397,22 @@ href="URI.html">URI</a>.
|
|
2381
2397
|
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
2382
2398
|
<div class="method-source-code" id="M000016-source">
|
2383
2399
|
<pre>
|
2384
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2385
|
-
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2400
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 530</span>
|
2401
|
+
530: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">user=</span>(<span class="ruby-identifier">new_user</span>)
|
2402
|
+
531: <span class="ruby-ivar">@user</span> = <span class="ruby-identifier">new_user</span>
|
2403
|
+
532:
|
2404
|
+
533: <span class="ruby-comment cmt"># You can't have a nil user with a non-nil password</span>
|
2405
|
+
534: <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>
|
2406
|
+
535: <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>
|
2407
|
+
536: <span class="ruby-keyword kw">end</span>
|
2408
|
+
537:
|
2409
|
+
538: <span class="ruby-comment cmt"># Reset dependant values</span>
|
2410
|
+
539: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-keyword kw">nil</span>
|
2411
|
+
540: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
|
2412
|
+
541:
|
2413
|
+
542: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
|
2414
|
+
543: <span class="ruby-identifier">validate</span>()
|
2415
|
+
544: <span class="ruby-keyword kw">end</span>
|
2400
2416
|
</pre>
|
2401
2417
|
</div>
|
2402
2418
|
</div>
|
@@ -2420,21 +2436,21 @@ this <a href="URI.html">URI</a>.
|
|
2420
2436
|
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
2421
2437
|
<div class="method-source-code" id="M000019-source">
|
2422
2438
|
<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
|
-
|
2439
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 569</span>
|
2440
|
+
569: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">userinfo</span>
|
2441
|
+
570: <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>
|
2442
|
+
571: <span class="ruby-identifier">current_user</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span>
|
2443
|
+
572: <span class="ruby-identifier">current_password</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span>
|
2444
|
+
573: <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>
|
2445
|
+
574: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-keyword kw">nil</span>
|
2446
|
+
575: <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>
|
2447
|
+
576: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-node">"#{current_user}:#{current_password}"</span>
|
2448
|
+
577: <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>
|
2449
|
+
578: <span class="ruby-ivar">@userinfo</span> = <span class="ruby-node">"#{current_user}"</span>
|
2450
|
+
579: <span class="ruby-keyword kw">end</span>
|
2451
|
+
580: <span class="ruby-keyword kw">end</span>
|
2452
|
+
581: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@userinfo</span>
|
2453
|
+
582: <span class="ruby-keyword kw">end</span>
|
2438
2454
|
</pre>
|
2439
2455
|
</div>
|
2440
2456
|
</div>
|
@@ -2458,21 +2474,21 @@ this <a href="URI.html">URI</a>.
|
|
2458
2474
|
onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
|
2459
2475
|
<div class="method-source-code" id="M000020-source">
|
2460
2476
|
<pre>
|
2461
|
-
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line
|
2462
|
-
|
2463
|
-
|
2464
|
-
|
2465
|
-
|
2466
|
-
|
2467
|
-
|
2468
|
-
|
2469
|
-
|
2470
|
-
|
2471
|
-
|
2472
|
-
|
2473
|
-
|
2474
|
-
|
2475
|
-
|
2477
|
+
<span class="ruby-comment cmt"># File lib/addressable/uri.rb, line 585</span>
|
2478
|
+
585: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">userinfo=</span>(<span class="ruby-identifier">new_userinfo</span>)
|
2479
|
+
586: <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>]
|
2480
|
+
587: <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>]
|
2481
|
+
588:
|
2482
|
+
589: <span class="ruby-comment cmt"># Password assigned first to ensure validity in case of nil</span>
|
2483
|
+
590: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">password</span> = <span class="ruby-identifier">new_password</span>
|
2484
|
+
591: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">user</span> = <span class="ruby-identifier">new_user</span>
|
2485
|
+
592:
|
2486
|
+
593: <span class="ruby-comment cmt"># Reset dependant values</span>
|
2487
|
+
594: <span class="ruby-ivar">@authority</span> = <span class="ruby-keyword kw">nil</span>
|
2488
|
+
595:
|
2489
|
+
596: <span class="ruby-comment cmt"># Ensure we haven't created an invalid URI</span>
|
2490
|
+
597: <span class="ruby-identifier">validate</span>()
|
2491
|
+
598: <span class="ruby-keyword kw">end</span>
|
2476
2492
|
</pre>
|
2477
2493
|
</div>
|
2478
2494
|
</div>
|