addressable 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/coverage/-Library-Ruby-Gems-1_8-gems-rcov-0_8_1_2_0-lib-rcov_rb.html +1 -1
- data/coverage/-Library-Ruby-Gems-1_8-gems-rspec-1_1_3-bin-spec.html +1 -1
- data/coverage/-Library-Ruby-Gems-1_8-gems-rspec-1_1_3-lib-spec_rb.html +1 -1
- data/coverage/-Library-Ruby-Gems-1_8-gems-rspec-1_1_3-plugins-mock_frameworks-rspec_rb.html +1 -1
- data/coverage/index.html +6 -6
- data/coverage/lib-addressable-uri_rb.html +735 -732
- data/coverage/lib-addressable-version_rb.html +33 -33
- data/lib/addressable/uri.rb +3 -0
- data/lib/addressable/version.rb +1 -1
- data/spec/addressable/uri_spec.rb +27 -5
- metadata +1 -1
data/CHANGELOG
CHANGED
@@ -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 Sat May 03 13:
|
556
|
+
<p>Generated on Sat May 03 13:17:30 -0400 2008 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...
|
@@ -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 Sat May 03 13:
|
556
|
+
<p>Generated on Sat May 03 13:17:30 -0400 2008 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...
|
@@ -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 Sat May 03 13:
|
556
|
+
<p>Generated on Sat May 03 13:17:30 -0400 2008 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...
|
@@ -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 Sat May 03 13:
|
556
|
+
<p>Generated on Sat May 03 13:17:30 -0400 2008 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...
|
data/coverage/index.html
CHANGED
@@ -148,7 +148,7 @@ table.report tr.dark {
|
|
148
148
|
</script>
|
149
149
|
</head>
|
150
150
|
<body><h3>C0 code coverage information</h3>
|
151
|
-
<p>Generated on Sat May 03 13:
|
151
|
+
<p>Generated on Sat May 03 13:17:30 -0400 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
152
152
|
</p>
|
153
153
|
<hr/>
|
154
154
|
<table class='report'><thead><tr><td class='heading'>Name</td>
|
@@ -159,9 +159,9 @@ table.report tr.dark {
|
|
159
159
|
</tr>
|
160
160
|
</thead>
|
161
161
|
<tbody><tr class='light'><td>TOTAL</td>
|
162
|
-
<td class='lines_total'><tt>
|
162
|
+
<td class='lines_total'><tt>2319</tt>
|
163
163
|
</td>
|
164
|
-
<td class='lines_code'><tt>
|
164
|
+
<td class='lines_code'><tt>1543</tt>
|
165
165
|
</td>
|
166
166
|
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>58.8%</tt>
|
167
167
|
</td>
|
@@ -173,7 +173,7 @@ table.report tr.dark {
|
|
173
173
|
</tr>
|
174
174
|
</table>
|
175
175
|
</td>
|
176
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>62.
|
176
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>62.1%</tt>
|
177
177
|
</td>
|
178
178
|
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='62'/>
|
179
179
|
<td class='uncovered' width='38'/>
|
@@ -294,9 +294,9 @@ table.report tr.dark {
|
|
294
294
|
</tr>
|
295
295
|
<tr class='dark'><td><a href='lib-addressable-uri_rb.html'>lib/addressable/uri.rb</a>
|
296
296
|
</td>
|
297
|
-
<td class='lines_total'><tt>
|
297
|
+
<td class='lines_total'><tt>1247</tt>
|
298
298
|
</td>
|
299
|
-
<td class='lines_code'><tt>
|
299
|
+
<td class='lines_code'><tt>887</tt>
|
300
300
|
</td>
|
301
301
|
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>100.0%</tt>
|
302
302
|
</td>
|
@@ -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 Sat May 03 13:
|
556
|
+
<p>Generated on Sat May 03 13:17:31 -0400 2008 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...
|
@@ -571,9 +571,9 @@ span.run100 {
|
|
571
571
|
</thead>
|
572
572
|
<tbody><tr class='light'><td><a href='lib-addressable-uri_rb.html'>lib/addressable/uri.rb</a>
|
573
573
|
</td>
|
574
|
-
<td class='lines_total'><tt>
|
574
|
+
<td class='lines_total'><tt>1247</tt>
|
575
575
|
</td>
|
576
|
-
<td class='lines_code'><tt>
|
576
|
+
<td class='lines_code'><tt>887</tt>
|
577
577
|
</td>
|
578
578
|
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>100.0%</tt>
|
579
579
|
</td>
|
@@ -1105,743 +1105,746 @@ span.run100 {
|
|
1105
1105
|
</span><span class="marked1"><a name="line505"></a> 505 @port = @port.to_i
|
1106
1106
|
</span><span class="marked0"><a name="line506"></a> 506 @port = nil if @port == 0
|
1107
1107
|
</span><span class="marked1"><a name="line507"></a> 507 @path = (path || "")
|
1108
|
-
</span><span class="marked0"><a name="line508"></a> 508 @
|
1109
|
-
</span><span class="marked1"><a name="line509"></a> 509
|
1110
|
-
</span><span class="inferred0"><a name="line510"></a> 510
|
1111
|
-
</span><span class="marked1"><a name="line511"></a> 511
|
1112
|
-
</span><span class="
|
1113
|
-
</span><span class="inferred1"><a name="line513"></a> 513
|
1114
|
-
</span><span class="
|
1115
|
-
</span><span class="
|
1116
|
-
</span><span class="
|
1117
|
-
</span><span class="
|
1118
|
-
</span><span class="
|
1119
|
-
</span><span class="
|
1120
|
-
</span><span class="marked0"><a name="line520"></a> 520
|
1121
|
-
</span><span class="
|
1122
|
-
</span><span class="
|
1123
|
-
</span><span class="
|
1124
|
-
</span><span class="
|
1125
|
-
</span><span class="marked1"><a name="line525"></a> 525
|
1126
|
-
</span><span class="
|
1127
|
-
</span><span class="
|
1128
|
-
</span><span class="
|
1129
|
-
</span><span class="
|
1130
|
-
</span><span class="marked0"><a name="line530"></a> 530
|
1131
|
-
</span><span class="
|
1132
|
-
</span><span class="inferred0"><a name="line532"></a> 532
|
1133
|
-
</span><span class="
|
1134
|
-
</span><span class="marked0"><a name="line534"></a> 534
|
1135
|
-
</span><span class="
|
1136
|
-
</span><span class="inferred0"><a name="line536"></a> 536
|
1137
|
-
</span><span class="
|
1138
|
-
</span><span class="
|
1139
|
-
</span><span class="
|
1140
|
-
</span><span class="
|
1141
|
-
</span><span class="inferred1"><a name="line541"></a> 541
|
1142
|
-
</span><span class="
|
1143
|
-
</span><span class="marked1"><a name="line543"></a> 543
|
1144
|
-
</span><span class="inferred0"><a name="line544"></a> 544
|
1145
|
-
</span><span class="inferred1"><a name="line545"></a> 545
|
1146
|
-
</span><span class="
|
1147
|
-
</span><span class="
|
1148
|
-
</span><span class="
|
1149
|
-
</span><span class="
|
1150
|
-
</span><span class="
|
1151
|
-
</span><span class="
|
1152
|
-
</span><span class="marked0"><a name="line552"></a> 552
|
1153
|
-
</span><span class="
|
1154
|
-
</span><span class="inferred0"><a name="line554"></a> 554
|
1155
|
-
</span><span class="
|
1156
|
-
</span><span class="marked0"><a name="line556"></a> 556
|
1157
|
-
</span><span class="
|
1158
|
-
</span><span class="inferred0"><a name="line558"></a> 558
|
1159
|
-
</span><span class="
|
1160
|
-
</span><span class="
|
1161
|
-
</span><span class="
|
1162
|
-
</span><span class="
|
1163
|
-
</span><span class="inferred1"><a name="line563"></a> 563
|
1164
|
-
</span><span class="
|
1165
|
-
</span><span class="marked1"><a name="line565"></a> 565
|
1166
|
-
</span><span class="inferred0"><a name="line566"></a> 566
|
1167
|
-
</span><span class="inferred1"><a name="line567"></a> 567
|
1168
|
-
</span><span class="
|
1169
|
-
</span><span class="
|
1170
|
-
</span><span class="
|
1171
|
-
</span><span class="
|
1172
|
-
</span><span class="marked0"><a name="line572"></a> 572
|
1173
|
-
</span><span class="marked1"><a name="line573"></a> 573
|
1174
|
-
</span><span class="marked0"><a name="line574"></a> 574
|
1175
|
-
</span><span class="marked1"><a name="line575"></a> 575
|
1176
|
-
</span><span class="marked0"><a name="line576"></a> 576
|
1177
|
-
</span><span class="marked1"><a name="line577"></a> 577
|
1178
|
-
</span><span class="marked0"><a name="line578"></a> 578
|
1179
|
-
</span><span class="
|
1180
|
-
</span><span class="
|
1181
|
-
</span><span class="marked1"><a name="line581"></a> 581
|
1182
|
-
</span><span class="inferred0"><a name="line582"></a> 582
|
1183
|
-
</span><span class="inferred1"><a name="line583"></a> 583
|
1184
|
-
</span><span class="
|
1185
|
-
</span><span class="
|
1186
|
-
</span><span class="
|
1187
|
-
</span><span class="
|
1188
|
-
</span><span class="
|
1189
|
-
</span><span class="
|
1190
|
-
</span><span class="marked0"><a name="line590"></a> 590
|
1191
|
-
</span><span class="
|
1192
|
-
</span><span class="inferred0"><a name="line592"></a> 592
|
1193
|
-
</span><span class="
|
1194
|
-
</span><span class="marked0"><a name="line594"></a> 594
|
1108
|
+
</span><span class="marked0"><a name="line508"></a> 508 if @path != "" && @path[0..0] != "/" && @host != nil
|
1109
|
+
</span><span class="marked1"><a name="line509"></a> 509 @path = "/#{@path}"
|
1110
|
+
</span><span class="inferred0"><a name="line510"></a> 510 end
|
1111
|
+
</span><span class="marked1"><a name="line511"></a> 511 @query = query
|
1112
|
+
</span><span class="marked0"><a name="line512"></a> 512 @fragment = fragment
|
1113
|
+
</span><span class="inferred1"><a name="line513"></a> 513
|
1114
|
+
</span><span class="marked0"><a name="line514"></a> 514 validate()
|
1115
|
+
</span><span class="inferred1"><a name="line515"></a> 515 end
|
1116
|
+
</span><span class="inferred0"><a name="line516"></a> 516
|
1117
|
+
</span><span class="inferred1"><a name="line517"></a> 517 # Returns the scheme (protocol) for this URI.
|
1118
|
+
</span><span class="marked0"><a name="line518"></a> 518 def scheme
|
1119
|
+
</span><span class="marked1"><a name="line519"></a> 519 return @scheme
|
1120
|
+
</span><span class="marked0"><a name="line520"></a> 520 end
|
1121
|
+
</span><span class="inferred1"><a name="line521"></a> 521
|
1122
|
+
</span><span class="inferred0"><a name="line522"></a> 522 # Sets the scheme (protocol for this URI.)
|
1123
|
+
</span><span class="marked1"><a name="line523"></a> 523 def scheme=(new_scheme)
|
1124
|
+
</span><span class="marked0"><a name="line524"></a> 524 @scheme = new_scheme
|
1125
|
+
</span><span class="marked1"><a name="line525"></a> 525 end
|
1126
|
+
</span><span class="inferred0"><a name="line526"></a> 526
|
1127
|
+
</span><span class="inferred1"><a name="line527"></a> 527 # Returns the user for this URI.
|
1128
|
+
</span><span class="marked0"><a name="line528"></a> 528 def user
|
1129
|
+
</span><span class="marked1"><a name="line529"></a> 529 return @user
|
1130
|
+
</span><span class="marked0"><a name="line530"></a> 530 end
|
1131
|
+
</span><span class="inferred1"><a name="line531"></a> 531
|
1132
|
+
</span><span class="inferred0"><a name="line532"></a> 532 # Sets the user for this URI.
|
1133
|
+
</span><span class="marked1"><a name="line533"></a> 533 def user=(new_user)
|
1134
|
+
</span><span class="marked0"><a name="line534"></a> 534 @user = new_user
|
1135
|
+
</span><span class="inferred1"><a name="line535"></a> 535
|
1136
|
+
</span><span class="inferred0"><a name="line536"></a> 536 # You can't have a nil user with a non-nil password
|
1137
|
+
</span><span class="marked1"><a name="line537"></a> 537 if @password != nil
|
1138
|
+
</span><span class="marked0"><a name="line538"></a> 538 @user = "" if @user.nil?
|
1139
|
+
</span><span class="inferred1"><a name="line539"></a> 539 end
|
1140
|
+
</span><span class="inferred0"><a name="line540"></a> 540
|
1141
|
+
</span><span class="inferred1"><a name="line541"></a> 541 # Reset dependant values
|
1142
|
+
</span><span class="marked0"><a name="line542"></a> 542 @userinfo = nil
|
1143
|
+
</span><span class="marked1"><a name="line543"></a> 543 @authority = nil
|
1144
|
+
</span><span class="inferred0"><a name="line544"></a> 544
|
1145
|
+
</span><span class="inferred1"><a name="line545"></a> 545 # Ensure we haven't created an invalid URI
|
1146
|
+
</span><span class="marked0"><a name="line546"></a> 546 validate()
|
1147
|
+
</span><span class="inferred1"><a name="line547"></a> 547 end
|
1148
|
+
</span><span class="inferred0"><a name="line548"></a> 548
|
1149
|
+
</span><span class="inferred1"><a name="line549"></a> 549 # Returns the password for this URI.
|
1150
|
+
</span><span class="marked0"><a name="line550"></a> 550 def password
|
1151
|
+
</span><span class="marked1"><a name="line551"></a> 551 return @password
|
1152
|
+
</span><span class="marked0"><a name="line552"></a> 552 end
|
1153
|
+
</span><span class="inferred1"><a name="line553"></a> 553
|
1154
|
+
</span><span class="inferred0"><a name="line554"></a> 554 # Sets the password for this URI.
|
1155
|
+
</span><span class="marked1"><a name="line555"></a> 555 def password=(new_password)
|
1156
|
+
</span><span class="marked0"><a name="line556"></a> 556 @password = new_password
|
1157
|
+
</span><span class="inferred1"><a name="line557"></a> 557
|
1158
|
+
</span><span class="inferred0"><a name="line558"></a> 558 # You can't have a nil user with a non-nil password
|
1159
|
+
</span><span class="marked1"><a name="line559"></a> 559 if @password != nil
|
1160
|
+
</span><span class="marked0"><a name="line560"></a> 560 @user = "" if @user.nil?
|
1161
|
+
</span><span class="inferred1"><a name="line561"></a> 561 end
|
1162
|
+
</span><span class="inferred0"><a name="line562"></a> 562
|
1163
|
+
</span><span class="inferred1"><a name="line563"></a> 563 # Reset dependant values
|
1164
|
+
</span><span class="marked0"><a name="line564"></a> 564 @userinfo = nil
|
1165
|
+
</span><span class="marked1"><a name="line565"></a> 565 @authority = nil
|
1166
|
+
</span><span class="inferred0"><a name="line566"></a> 566
|
1167
|
+
</span><span class="inferred1"><a name="line567"></a> 567 # Ensure we haven't created an invalid URI
|
1168
|
+
</span><span class="marked0"><a name="line568"></a> 568 validate()
|
1169
|
+
</span><span class="inferred1"><a name="line569"></a> 569 end
|
1170
|
+
</span><span class="inferred0"><a name="line570"></a> 570
|
1171
|
+
</span><span class="inferred1"><a name="line571"></a> 571 # Returns the username and password segment of this URI.
|
1172
|
+
</span><span class="marked0"><a name="line572"></a> 572 def userinfo
|
1173
|
+
</span><span class="marked1"><a name="line573"></a> 573 if !defined?(@userinfo) || @userinfo == nil
|
1174
|
+
</span><span class="marked0"><a name="line574"></a> 574 current_user = self.user
|
1175
|
+
</span><span class="marked1"><a name="line575"></a> 575 current_password = self.password
|
1176
|
+
</span><span class="marked0"><a name="line576"></a> 576 if !current_user && !current_password
|
1177
|
+
</span><span class="marked1"><a name="line577"></a> 577 @userinfo = nil
|
1178
|
+
</span><span class="marked0"><a name="line578"></a> 578 elsif current_user && current_password
|
1179
|
+
</span><span class="marked1"><a name="line579"></a> 579 @userinfo = "#{current_user}:#{current_password}"
|
1180
|
+
</span><span class="marked0"><a name="line580"></a> 580 elsif current_user && !current_password
|
1181
|
+
</span><span class="marked1"><a name="line581"></a> 581 @userinfo = "#{current_user}"
|
1182
|
+
</span><span class="inferred0"><a name="line582"></a> 582 end
|
1183
|
+
</span><span class="inferred1"><a name="line583"></a> 583 end
|
1184
|
+
</span><span class="marked0"><a name="line584"></a> 584 return @userinfo
|
1185
|
+
</span><span class="inferred1"><a name="line585"></a> 585 end
|
1186
|
+
</span><span class="inferred0"><a name="line586"></a> 586
|
1187
|
+
</span><span class="inferred1"><a name="line587"></a> 587 # Sets the username and password segment of this URI.
|
1188
|
+
</span><span class="marked0"><a name="line588"></a> 588 def userinfo=(new_userinfo)
|
1189
|
+
</span><span class="marked1"><a name="line589"></a> 589 new_user = new_userinfo.to_s.strip.scan(/^(.*):/).flatten[0]
|
1190
|
+
</span><span class="marked0"><a name="line590"></a> 590 new_password = new_userinfo.to_s.strip.scan(/:(.*)$/).flatten[0]
|
1191
|
+
</span><span class="inferred1"><a name="line591"></a> 591
|
1192
|
+
</span><span class="inferred0"><a name="line592"></a> 592 # Password assigned first to ensure validity in case of nil
|
1193
|
+
</span><span class="marked1"><a name="line593"></a> 593 self.password = new_password
|
1194
|
+
</span><span class="marked0"><a name="line594"></a> 594 self.user = new_user
|
1195
1195
|
</span><span class="inferred1"><a name="line595"></a> 595
|
1196
|
-
</span><span class="inferred0"><a name="line596"></a> 596 #
|
1197
|
-
</span><span class="marked1"><a name="line597"></a> 597
|
1198
|
-
</span><span class="inferred0"><a name="line598"></a> 598
|
1199
|
-
</span><span class="inferred1"><a name="line599"></a> 599
|
1200
|
-
</span><span class="
|
1201
|
-
</span><span class="
|
1202
|
-
</span><span class="
|
1203
|
-
</span><span class="
|
1204
|
-
</span><span class="
|
1205
|
-
</span><span class="
|
1206
|
-
</span><span class="marked0"><a name="line606"></a> 606
|
1207
|
-
</span><span class="
|
1208
|
-
</span><span class="inferred0"><a name="line608"></a> 608
|
1209
|
-
</span><span class="
|
1210
|
-
</span><span class="marked0"><a name="line610"></a> 610 @
|
1196
|
+
</span><span class="inferred0"><a name="line596"></a> 596 # Reset dependant values
|
1197
|
+
</span><span class="marked1"><a name="line597"></a> 597 @authority = nil
|
1198
|
+
</span><span class="inferred0"><a name="line598"></a> 598
|
1199
|
+
</span><span class="inferred1"><a name="line599"></a> 599 # Ensure we haven't created an invalid URI
|
1200
|
+
</span><span class="marked0"><a name="line600"></a> 600 validate()
|
1201
|
+
</span><span class="inferred1"><a name="line601"></a> 601 end
|
1202
|
+
</span><span class="inferred0"><a name="line602"></a> 602
|
1203
|
+
</span><span class="inferred1"><a name="line603"></a> 603 # Returns the host for this URI.
|
1204
|
+
</span><span class="marked0"><a name="line604"></a> 604 def host
|
1205
|
+
</span><span class="marked1"><a name="line605"></a> 605 return @host
|
1206
|
+
</span><span class="marked0"><a name="line606"></a> 606 end
|
1207
|
+
</span><span class="inferred1"><a name="line607"></a> 607
|
1208
|
+
</span><span class="inferred0"><a name="line608"></a> 608 # Sets the host for this URI.
|
1209
|
+
</span><span class="marked1"><a name="line609"></a> 609 def host=(new_host)
|
1210
|
+
</span><span class="marked0"><a name="line610"></a> 610 @host = new_host
|
1211
1211
|
</span><span class="inferred1"><a name="line611"></a> 611
|
1212
|
-
</span><span class="inferred0"><a name="line612"></a> 612 #
|
1213
|
-
</span><span class="marked1"><a name="line613"></a> 613
|
1214
|
-
</span><span class="inferred0"><a name="line614"></a> 614
|
1215
|
-
</span><span class="inferred1"><a name="line615"></a> 615
|
1216
|
-
</span><span class="
|
1217
|
-
</span><span class="
|
1218
|
-
</span><span class="
|
1219
|
-
</span><span class="
|
1220
|
-
</span><span class="marked0"><a name="line620"></a> 620
|
1221
|
-
</span><span class="marked1"><a name="line621"></a> 621
|
1222
|
-
</span><span class="marked0"><a name="line622"></a> 622
|
1223
|
-
</span><span class="
|
1224
|
-
</span><span class="marked0"><a name="line624"></a> 624
|
1225
|
-
</span><span class="marked1"><a name="line625"></a> 625
|
1226
|
-
</span><span class="
|
1227
|
-
</span><span class="
|
1228
|
-
</span><span class="
|
1229
|
-
</span><span class="marked1"><a name="line629"></a> 629
|
1230
|
-
</span><span class="inferred0"><a name="line630"></a> 630
|
1231
|
-
</span><span class="inferred1"><a name="line631"></a> 631
|
1232
|
-
</span><span class="
|
1233
|
-
</span><span class="
|
1234
|
-
</span><span class="
|
1235
|
-
</span><span class="
|
1236
|
-
</span><span class="marked0"><a name="line636"></a> 636
|
1237
|
-
</span><span class="marked1"><a name="line637"></a> 637
|
1238
|
-
</span><span class="marked0"><a name="line638"></a> 638
|
1239
|
-
</span><span class="
|
1240
|
-
</span><span class="marked0"><a name="line640"></a> 640
|
1241
|
-
</span><span class="
|
1242
|
-
</span><span class="
|
1243
|
-
</span><span class="
|
1244
|
-
</span><span class="inferred0"><a name="line644"></a> 644
|
1245
|
-
</span><span class="
|
1246
|
-
</span><span class="inferred0"><a name="line646"></a> 646
|
1247
|
-
</span><span class="
|
1248
|
-
</span><span class="
|
1249
|
-
</span><span class="
|
1250
|
-
</span><span class="
|
1251
|
-
</span><span class="
|
1252
|
-
</span><span class="marked0"><a name="line652"></a> 652
|
1253
|
-
</span><span class="
|
1254
|
-
</span><span class="inferred0"><a name="line654"></a> 654
|
1255
|
-
</span><span class="
|
1256
|
-
</span><span class="marked0"><a name="line656"></a> 656
|
1257
|
-
</span><span class="inferred1"><a name="line657"></a> 657
|
1258
|
-
</span><span class="inferred0"><a name="line658"></a> 658
|
1259
|
-
</span><span class="
|
1260
|
-
</span><span class="inferred0"><a name="line660"></a> 660
|
1261
|
-
</span><span class="inferred1"><a name="line661"></a> 661
|
1262
|
-
</span><span class="
|
1263
|
-
</span><span class="
|
1264
|
-
</span><span class="
|
1265
|
-
</span><span class="
|
1266
|
-
</span><span class="
|
1267
|
-
</span><span class="
|
1268
|
-
</span><span class="inferred0"><a name="line668"></a> 668
|
1269
|
-
</span><span class="
|
1270
|
-
</span><span class="
|
1271
|
-
</span><span class="
|
1272
|
-
</span><span class="
|
1273
|
-
</span><span class="
|
1274
|
-
</span><span class="
|
1275
|
-
</span><span class="inferred1"><a name="line675"></a> 675 "
|
1276
|
-
</span><span class="inferred0"><a name="line676"></a> 676 "
|
1277
|
-
</span><span class="inferred1"><a name="line677"></a> 677 "
|
1278
|
-
</span><span class="inferred0"><a name="line678"></a> 678 "
|
1279
|
-
</span><span class="inferred1"><a name="line679"></a> 679 "
|
1280
|
-
</span><span class="inferred0"><a name="line680"></a> 680 "
|
1281
|
-
</span><span class="inferred1"><a name="line681"></a> 681 "
|
1282
|
-
</span><span class="inferred0"><a name="line682"></a> 682 "
|
1283
|
-
</span><span class="inferred1"><a name="line683"></a> 683 "
|
1284
|
-
</span><span class="inferred0"><a name="line684"></a> 684
|
1285
|
-
</span><span class="inferred1"><a name="line685"></a> 685
|
1286
|
-
</span><span class="
|
1287
|
-
</span><span class="inferred1"><a name="line687"></a> 687
|
1288
|
-
</span><span class="inferred0"><a name="line688"></a> 688
|
1289
|
-
</span><span class="
|
1290
|
-
</span><span class="inferred0"><a name="line690"></a> 690
|
1291
|
-
</span><span class="inferred1"><a name="line691"></a> 691
|
1292
|
-
</span><span class="
|
1293
|
-
</span><span class="
|
1294
|
-
</span><span class="
|
1295
|
-
</span><span class="marked1"><a name="line695"></a> 695
|
1296
|
-
</span><span class="
|
1297
|
-
</span><span class="marked1"><a name="line697"></a> 697
|
1298
|
-
</span><span class="
|
1299
|
-
</span><span class="
|
1300
|
-
</span><span class="
|
1301
|
-
</span><span class="
|
1212
|
+
</span><span class="inferred0"><a name="line612"></a> 612 # Reset dependant values
|
1213
|
+
</span><span class="marked1"><a name="line613"></a> 613 @authority = nil
|
1214
|
+
</span><span class="inferred0"><a name="line614"></a> 614
|
1215
|
+
</span><span class="inferred1"><a name="line615"></a> 615 # Ensure we haven't created an invalid URI
|
1216
|
+
</span><span class="marked0"><a name="line616"></a> 616 validate()
|
1217
|
+
</span><span class="inferred1"><a name="line617"></a> 617 end
|
1218
|
+
</span><span class="inferred0"><a name="line618"></a> 618
|
1219
|
+
</span><span class="inferred1"><a name="line619"></a> 619 # Returns the authority segment of this URI.
|
1220
|
+
</span><span class="marked0"><a name="line620"></a> 620 def authority
|
1221
|
+
</span><span class="marked1"><a name="line621"></a> 621 if !defined?(@authority) || @authority.nil?
|
1222
|
+
</span><span class="marked0"><a name="line622"></a> 622 return nil if self.host.nil?
|
1223
|
+
</span><span class="marked1"><a name="line623"></a> 623 @authority = ""
|
1224
|
+
</span><span class="marked0"><a name="line624"></a> 624 if self.userinfo != nil
|
1225
|
+
</span><span class="marked1"><a name="line625"></a> 625 @authority << "#{self.userinfo}@"
|
1226
|
+
</span><span class="inferred0"><a name="line626"></a> 626 end
|
1227
|
+
</span><span class="marked1"><a name="line627"></a> 627 @authority << self.host
|
1228
|
+
</span><span class="marked0"><a name="line628"></a> 628 if self.specified_port != nil
|
1229
|
+
</span><span class="marked1"><a name="line629"></a> 629 @authority << ":#{self.specified_port}"
|
1230
|
+
</span><span class="inferred0"><a name="line630"></a> 630 end
|
1231
|
+
</span><span class="inferred1"><a name="line631"></a> 631 end
|
1232
|
+
</span><span class="marked0"><a name="line632"></a> 632 return @authority
|
1233
|
+
</span><span class="inferred1"><a name="line633"></a> 633 end
|
1234
|
+
</span><span class="inferred0"><a name="line634"></a> 634
|
1235
|
+
</span><span class="inferred1"><a name="line635"></a> 635 # Sets the authority segment of this URI.
|
1236
|
+
</span><span class="marked0"><a name="line636"></a> 636 def authority=(new_authority)
|
1237
|
+
</span><span class="marked1"><a name="line637"></a> 637 if new_authority
|
1238
|
+
</span><span class="marked0"><a name="line638"></a> 638 new_userinfo = new_authority.scan(/^([^\[\]]*)@/).flatten[0]
|
1239
|
+
</span><span class="marked1"><a name="line639"></a> 639 if new_userinfo
|
1240
|
+
</span><span class="marked0"><a name="line640"></a> 640 new_user = new_userinfo.strip.scan(/^([^:]*):?/).flatten[0]
|
1241
|
+
</span><span class="marked1"><a name="line641"></a> 641 new_password = new_userinfo.strip.scan(/:(.*)$/).flatten[0]
|
1242
|
+
</span><span class="inferred0"><a name="line642"></a> 642 end
|
1243
|
+
</span><span class="marked1"><a name="line643"></a> 643 new_host =
|
1244
|
+
</span><span class="inferred0"><a name="line644"></a> 644 new_authority.gsub(/^([^\[\]]*)@/, "").gsub(/:([^:@\[\]]*?)$/, "")
|
1245
|
+
</span><span class="marked1"><a name="line645"></a> 645 new_port =
|
1246
|
+
</span><span class="inferred0"><a name="line646"></a> 646 new_authority.scan(/:([^:@\[\]]*?)$/).flatten[0]
|
1247
|
+
</span><span class="inferred1"><a name="line647"></a> 647 end
|
1248
|
+
</span><span class="inferred0"><a name="line648"></a> 648
|
1249
|
+
</span><span class="inferred1"><a name="line649"></a> 649 # Password assigned first to ensure validity in case of nil
|
1250
|
+
</span><span class="marked0"><a name="line650"></a> 650 self.password = new_password
|
1251
|
+
</span><span class="marked1"><a name="line651"></a> 651 self.user = new_user
|
1252
|
+
</span><span class="marked0"><a name="line652"></a> 652 self.host = new_host
|
1253
|
+
</span><span class="inferred1"><a name="line653"></a> 653
|
1254
|
+
</span><span class="inferred0"><a name="line654"></a> 654 # Port reset to allow port normalization
|
1255
|
+
</span><span class="marked1"><a name="line655"></a> 655 @port = nil
|
1256
|
+
</span><span class="marked0"><a name="line656"></a> 656 @specified_port = new_port
|
1257
|
+
</span><span class="inferred1"><a name="line657"></a> 657
|
1258
|
+
</span><span class="inferred0"><a name="line658"></a> 658 # Ensure we haven't created an invalid URI
|
1259
|
+
</span><span class="marked1"><a name="line659"></a> 659 validate()
|
1260
|
+
</span><span class="inferred0"><a name="line660"></a> 660 end
|
1261
|
+
</span><span class="inferred1"><a name="line661"></a> 661
|
1262
|
+
</span><span class="inferred0"><a name="line662"></a> 662 # Returns an array of known ip-based schemes. These schemes typically
|
1263
|
+
</span><span class="inferred1"><a name="line663"></a> 663 # use a similar URI form:
|
1264
|
+
</span><span class="inferred0"><a name="line664"></a> 664 # //<user>:<password>@<host>:<port>/<url-path>
|
1265
|
+
</span><span class="marked1"><a name="line665"></a> 665 def self.ip_based_schemes
|
1266
|
+
</span><span class="marked0"><a name="line666"></a> 666 return self.scheme_mapping.keys
|
1267
|
+
</span><span class="marked1"><a name="line667"></a> 667 end
|
1268
|
+
</span><span class="inferred0"><a name="line668"></a> 668
|
1269
|
+
</span><span class="inferred1"><a name="line669"></a> 669 # Returns a hash of common IP-based schemes and their default port
|
1270
|
+
</span><span class="inferred0"><a name="line670"></a> 670 # numbers. Adding new schemes to this hash, as necessary, will allow
|
1271
|
+
</span><span class="inferred1"><a name="line671"></a> 671 # for better URI normalization.
|
1272
|
+
</span><span class="marked0"><a name="line672"></a> 672 def self.scheme_mapping
|
1273
|
+
</span><span class="marked1"><a name="line673"></a> 673 if !defined?(@protocol_mapping) || @protocol_mapping.nil?
|
1274
|
+
</span><span class="marked0"><a name="line674"></a> 674 @protocol_mapping = {
|
1275
|
+
</span><span class="inferred1"><a name="line675"></a> 675 "http" => 80,
|
1276
|
+
</span><span class="inferred0"><a name="line676"></a> 676 "https" => 443,
|
1277
|
+
</span><span class="inferred1"><a name="line677"></a> 677 "ftp" => 21,
|
1278
|
+
</span><span class="inferred0"><a name="line678"></a> 678 "tftp" => 69,
|
1279
|
+
</span><span class="inferred1"><a name="line679"></a> 679 "ssh" => 22,
|
1280
|
+
</span><span class="inferred0"><a name="line680"></a> 680 "svn+ssh" => 22,
|
1281
|
+
</span><span class="inferred1"><a name="line681"></a> 681 "telnet" => 23,
|
1282
|
+
</span><span class="inferred0"><a name="line682"></a> 682 "nntp" => 119,
|
1283
|
+
</span><span class="inferred1"><a name="line683"></a> 683 "gopher" => 70,
|
1284
|
+
</span><span class="inferred0"><a name="line684"></a> 684 "wais" => 210,
|
1285
|
+
</span><span class="inferred1"><a name="line685"></a> 685 "ldap" => 389,
|
1286
|
+
</span><span class="inferred0"><a name="line686"></a> 686 "prospero" => 1525
|
1287
|
+
</span><span class="inferred1"><a name="line687"></a> 687 }
|
1288
|
+
</span><span class="inferred0"><a name="line688"></a> 688 end
|
1289
|
+
</span><span class="marked1"><a name="line689"></a> 689 return @protocol_mapping
|
1290
|
+
</span><span class="inferred0"><a name="line690"></a> 690 end
|
1291
|
+
</span><span class="inferred1"><a name="line691"></a> 691
|
1292
|
+
</span><span class="inferred0"><a name="line692"></a> 692 # Returns the port number for this URI. This method will normalize to the
|
1293
|
+
</span><span class="inferred1"><a name="line693"></a> 693 # default port for the URI's scheme if the port isn't explicitly specified
|
1294
|
+
</span><span class="inferred0"><a name="line694"></a> 694 # in the URI.
|
1295
|
+
</span><span class="marked1"><a name="line695"></a> 695 def port
|
1296
|
+
</span><span class="marked0"><a name="line696"></a> 696 if @port.to_i == 0
|
1297
|
+
</span><span class="marked1"><a name="line697"></a> 697 if self.scheme
|
1298
|
+
</span><span class="marked0"><a name="line698"></a> 698 @port = self.class.scheme_mapping[self.scheme.strip.downcase]
|
1299
|
+
</span><span class="inferred1"><a name="line699"></a> 699 else
|
1300
|
+
</span><span class="marked0"><a name="line700"></a> 700 @port = nil
|
1301
|
+
</span><span class="inferred1"><a name="line701"></a> 701 end
|
1302
1302
|
</span><span class="marked0"><a name="line702"></a> 702 return @port
|
1303
|
-
</span><span class="inferred1"><a name="line703"></a> 703
|
1304
|
-
</span><span class="marked0"><a name="line704"></a> 704
|
1305
|
-
</span><span class="
|
1306
|
-
</span><span class="inferred0"><a name="line706"></a> 706
|
1307
|
-
</span><span class="marked1"><a name="line707"></a> 707
|
1308
|
-
</span><span class="
|
1309
|
-
</span><span class="
|
1310
|
-
</span><span class="marked0"><a name="line710"></a> 710
|
1311
|
-
</span><span class="
|
1312
|
-
</span><span class="
|
1313
|
-
</span><span class="
|
1314
|
-
</span><span class="
|
1315
|
-
</span><span class="
|
1316
|
-
</span><span class="
|
1317
|
-
</span><span class="marked1"><a name="line717"></a> 717
|
1318
|
-
</span><span class="
|
1319
|
-
</span><span class="marked1"><a name="line719"></a> 719
|
1320
|
-
</span><span class="
|
1321
|
-
</span><span class="inferred1"><a name="line721"></a> 721
|
1322
|
-
</span><span class="
|
1323
|
-
</span><span class="inferred1"><a name="line723"></a> 723
|
1324
|
-
</span><span class="
|
1325
|
-
</span><span class="
|
1326
|
-
</span><span class="
|
1327
|
-
</span><span class="
|
1328
|
-
</span><span class="
|
1329
|
-
</span><span class="marked1"><a name="line729"></a> 729
|
1330
|
-
</span><span class="
|
1331
|
-
</span><span class="
|
1332
|
-
</span><span class="
|
1333
|
-
</span><span class="
|
1334
|
-
</span><span class="
|
1335
|
-
</span><span class="
|
1336
|
-
</span><span class="inferred0"><a name="line736"></a> 736
|
1337
|
-
</span><span class="
|
1338
|
-
</span><span class="marked0"><a name="line738"></a> 738
|
1339
|
-
</span><span class="inferred1"><a name="line739"></a> 739
|
1340
|
-
</span><span class="
|
1341
|
-
</span><span class="
|
1342
|
-
</span><span class="inferred0"><a name="line742"></a> 742
|
1343
|
-
</span><span class="
|
1344
|
-
</span><span class="
|
1345
|
-
</span><span class="
|
1346
|
-
</span><span class="
|
1347
|
-
</span><span class="
|
1348
|
-
</span><span class="
|
1349
|
-
</span><span class="
|
1350
|
-
</span><span class="
|
1351
|
-
</span><span class="
|
1352
|
-
</span><span class="
|
1353
|
-
</span><span class="
|
1354
|
-
</span><span class="marked0"><a name="line754"></a> 754
|
1355
|
-
</span><span class="
|
1356
|
-
</span><span class="
|
1357
|
-
</span><span class="
|
1358
|
-
</span><span class="
|
1359
|
-
</span><span class="marked1"><a name="line759"></a> 759
|
1360
|
-
</span><span class="
|
1361
|
-
</span><span class="
|
1362
|
-
</span><span class="
|
1363
|
-
</span><span class="
|
1364
|
-
</span><span class="marked0"><a name="line764"></a> 764
|
1365
|
-
</span><span class="
|
1366
|
-
</span><span class="
|
1367
|
-
</span><span class="
|
1368
|
-
</span><span class="
|
1369
|
-
</span><span class="marked1"><a name="line769"></a> 769
|
1370
|
-
</span><span class="
|
1371
|
-
</span><span class="
|
1372
|
-
</span><span class="marked0"><a name="line772"></a> 772
|
1373
|
-
</span><span class="
|
1374
|
-
</span><span class="marked0"><a name="line774"></a> 774
|
1375
|
-
</span><span class="
|
1376
|
-
</span><span class="inferred0"><a name="line776"></a> 776
|
1377
|
-
</span><span class="
|
1378
|
-
</span><span class="
|
1379
|
-
</span><span class="
|
1380
|
-
</span><span class="
|
1381
|
-
</span><span class="
|
1382
|
-
</span><span class="
|
1383
|
-
</span><span class="marked1"><a name="line783"></a> 783
|
1384
|
-
</span><span class="
|
1385
|
-
</span><span class="
|
1386
|
-
</span><span class="
|
1387
|
-
</span><span class="
|
1388
|
-
</span><span class="marked0"><a name="line788"></a> 788
|
1389
|
-
</span><span class="
|
1390
|
-
</span><span class="
|
1391
|
-
</span><span class="
|
1392
|
-
</span><span class="marked0"><a name="line792"></a> 792 if uri.
|
1393
|
-
</span><span class="marked1"><a name="line793"></a> 793
|
1303
|
+
</span><span class="inferred1"><a name="line703"></a> 703 else
|
1304
|
+
</span><span class="marked0"><a name="line704"></a> 704 @port = @port.to_i
|
1305
|
+
</span><span class="marked1"><a name="line705"></a> 705 return @port
|
1306
|
+
</span><span class="inferred0"><a name="line706"></a> 706 end
|
1307
|
+
</span><span class="marked1"><a name="line707"></a> 707 end
|
1308
|
+
</span><span class="inferred0"><a name="line708"></a> 708
|
1309
|
+
</span><span class="inferred1"><a name="line709"></a> 709 # Sets the port for this URI.
|
1310
|
+
</span><span class="marked0"><a name="line710"></a> 710 def port=(new_port)
|
1311
|
+
</span><span class="marked1"><a name="line711"></a> 711 @port = new_port.to_s.to_i
|
1312
|
+
</span><span class="marked0"><a name="line712"></a> 712 @specified_port = @port
|
1313
|
+
</span><span class="marked1"><a name="line713"></a> 713 @authority = nil
|
1314
|
+
</span><span class="inferred0"><a name="line714"></a> 714 end
|
1315
|
+
</span><span class="inferred1"><a name="line715"></a> 715
|
1316
|
+
</span><span class="inferred0"><a name="line716"></a> 716 # Returns the port number that was actually specified in the URI string.
|
1317
|
+
</span><span class="marked1"><a name="line717"></a> 717 def specified_port
|
1318
|
+
</span><span class="marked0"><a name="line718"></a> 718 port = @specified_port.to_s.to_i
|
1319
|
+
</span><span class="marked1"><a name="line719"></a> 719 if port == 0
|
1320
|
+
</span><span class="marked0"><a name="line720"></a> 720 return nil
|
1321
|
+
</span><span class="inferred1"><a name="line721"></a> 721 else
|
1322
|
+
</span><span class="marked0"><a name="line722"></a> 722 return port
|
1323
|
+
</span><span class="inferred1"><a name="line723"></a> 723 end
|
1324
|
+
</span><span class="inferred0"><a name="line724"></a> 724 end
|
1325
|
+
</span><span class="inferred1"><a name="line725"></a> 725
|
1326
|
+
</span><span class="inferred0"><a name="line726"></a> 726 # Returns the path for this URI.
|
1327
|
+
</span><span class="marked1"><a name="line727"></a> 727 def path
|
1328
|
+
</span><span class="marked0"><a name="line728"></a> 728 return @path
|
1329
|
+
</span><span class="marked1"><a name="line729"></a> 729 end
|
1330
|
+
</span><span class="inferred0"><a name="line730"></a> 730
|
1331
|
+
</span><span class="inferred1"><a name="line731"></a> 731 # Sets the path for this URI.
|
1332
|
+
</span><span class="marked0"><a name="line732"></a> 732 def path=(new_path)
|
1333
|
+
</span><span class="marked1"><a name="line733"></a> 733 @path = (new_path || "")
|
1334
|
+
</span><span class="marked0"><a name="line734"></a> 734 end
|
1335
|
+
</span><span class="inferred1"><a name="line735"></a> 735
|
1336
|
+
</span><span class="inferred0"><a name="line736"></a> 736 # Returns the basename, if any, of the file at the path being referenced.
|
1337
|
+
</span><span class="inferred1"><a name="line737"></a> 737 # Returns nil if there is no path component.
|
1338
|
+
</span><span class="marked0"><a name="line738"></a> 738 def basename
|
1339
|
+
</span><span class="inferred1"><a name="line739"></a> 739 # Path cannot be nil
|
1340
|
+
</span><span class="marked0"><a name="line740"></a> 740 return File.basename(self.path).gsub(/;[^\/]*$/, "")
|
1341
|
+
</span><span class="marked1"><a name="line741"></a> 741 end
|
1342
|
+
</span><span class="inferred0"><a name="line742"></a> 742
|
1343
|
+
</span><span class="inferred1"><a name="line743"></a> 743 # Returns the extension, if any, of the file at the path being referenced.
|
1344
|
+
</span><span class="inferred0"><a name="line744"></a> 744 # Returns "" if there is no extension or nil if there is no path
|
1345
|
+
</span><span class="inferred1"><a name="line745"></a> 745 # component.
|
1346
|
+
</span><span class="marked0"><a name="line746"></a> 746 def extname
|
1347
|
+
</span><span class="marked1"><a name="line747"></a> 747 return nil unless self.path
|
1348
|
+
</span><span class="marked0"><a name="line748"></a> 748 return File.extname(self.basename)
|
1349
|
+
</span><span class="inferred1"><a name="line749"></a> 749 end
|
1350
|
+
</span><span class="inferred0"><a name="line750"></a> 750
|
1351
|
+
</span><span class="inferred1"><a name="line751"></a> 751 # Returns the query string for this URI.
|
1352
|
+
</span><span class="marked0"><a name="line752"></a> 752 def query
|
1353
|
+
</span><span class="marked1"><a name="line753"></a> 753 return @query
|
1354
|
+
</span><span class="marked0"><a name="line754"></a> 754 end
|
1355
|
+
</span><span class="inferred1"><a name="line755"></a> 755
|
1356
|
+
</span><span class="inferred0"><a name="line756"></a> 756 # Sets the query string for this URI.
|
1357
|
+
</span><span class="marked1"><a name="line757"></a> 757 def query=(new_query)
|
1358
|
+
</span><span class="marked0"><a name="line758"></a> 758 @query = new_query
|
1359
|
+
</span><span class="marked1"><a name="line759"></a> 759 end
|
1360
|
+
</span><span class="inferred0"><a name="line760"></a> 760
|
1361
|
+
</span><span class="inferred1"><a name="line761"></a> 761 # Returns the fragment for this URI.
|
1362
|
+
</span><span class="marked0"><a name="line762"></a> 762 def fragment
|
1363
|
+
</span><span class="marked1"><a name="line763"></a> 763 return @fragment
|
1364
|
+
</span><span class="marked0"><a name="line764"></a> 764 end
|
1365
|
+
</span><span class="inferred1"><a name="line765"></a> 765
|
1366
|
+
</span><span class="inferred0"><a name="line766"></a> 766 # Sets the fragment for this URI.
|
1367
|
+
</span><span class="marked1"><a name="line767"></a> 767 def fragment=(new_fragment)
|
1368
|
+
</span><span class="marked0"><a name="line768"></a> 768 @fragment = new_fragment
|
1369
|
+
</span><span class="marked1"><a name="line769"></a> 769 end
|
1370
|
+
</span><span class="inferred0"><a name="line770"></a> 770
|
1371
|
+
</span><span class="inferred1"><a name="line771"></a> 771 # Returns true if the URI uses an IP-based protocol.
|
1372
|
+
</span><span class="marked0"><a name="line772"></a> 772 def ip_based?
|
1373
|
+
</span><span class="marked1"><a name="line773"></a> 773 if self.scheme
|
1374
|
+
</span><span class="marked0"><a name="line774"></a> 774 return self.class.ip_based_schemes.include?(
|
1375
|
+
</span><span class="marked1"><a name="line775"></a> 775 self.scheme.strip.downcase)
|
1376
|
+
</span><span class="inferred0"><a name="line776"></a> 776 end
|
1377
|
+
</span><span class="marked1"><a name="line777"></a> 777 return false
|
1378
|
+
</span><span class="inferred0"><a name="line778"></a> 778 end
|
1379
|
+
</span><span class="inferred1"><a name="line779"></a> 779
|
1380
|
+
</span><span class="inferred0"><a name="line780"></a> 780 # Returns true if this URI is known to be relative.
|
1381
|
+
</span><span class="marked1"><a name="line781"></a> 781 def relative?
|
1382
|
+
</span><span class="marked0"><a name="line782"></a> 782 return self.scheme.nil?
|
1383
|
+
</span><span class="marked1"><a name="line783"></a> 783 end
|
1384
|
+
</span><span class="inferred0"><a name="line784"></a> 784
|
1385
|
+
</span><span class="inferred1"><a name="line785"></a> 785 # Returns true if this URI is known to be absolute.
|
1386
|
+
</span><span class="marked0"><a name="line786"></a> 786 def absolute?
|
1387
|
+
</span><span class="marked1"><a name="line787"></a> 787 return !relative?
|
1388
|
+
</span><span class="marked0"><a name="line788"></a> 788 end
|
1389
|
+
</span><span class="inferred1"><a name="line789"></a> 789
|
1390
|
+
</span><span class="inferred0"><a name="line790"></a> 790 # Joins two URIs together.
|
1391
|
+
</span><span class="marked1"><a name="line791"></a> 791 def +(uri)
|
1392
|
+
</span><span class="marked0"><a name="line792"></a> 792 if !uri.kind_of?(self.class)
|
1393
|
+
</span><span class="marked1"><a name="line793"></a> 793 uri = URI.parse(uri.to_s)
|
1394
1394
|
</span><span class="inferred0"><a name="line794"></a> 794 end
|
1395
|
-
</span><span class="
|
1396
|
-
</span><span class="marked0"><a name="line796"></a> 796
|
1397
|
-
</span><span class="
|
1398
|
-
</span><span class="
|
1399
|
-
</span><span class="marked1"><a name="line799"></a> 799
|
1400
|
-
</span><span class="marked0"><a name="line800"></a> 800
|
1401
|
-
</span><span class="marked1"><a name="line801"></a> 801
|
1402
|
-
</span><span class="marked0"><a name="line802"></a> 802
|
1403
|
-
</span><span class="marked1"><a name="line803"></a> 803
|
1404
|
-
</span><span class="
|
1405
|
-
</span><span class="
|
1406
|
-
</span><span class="marked0"><a name="line806"></a> 806
|
1407
|
-
</span><span class="
|
1408
|
-
</span><span class="
|
1409
|
-
</span><span class="marked1"><a name="line809"></a> 809
|
1410
|
-
</span><span class="marked0"><a name="line810"></a> 810
|
1411
|
-
</span><span class="marked1"><a name="line811"></a> 811
|
1412
|
-
</span><span class="marked0"><a name="line812"></a> 812
|
1413
|
-
</span><span class="marked1"><a name="line813"></a> 813
|
1414
|
-
</span><span class="
|
1415
|
-
</span><span class="marked1"><a name="line815"></a> 815
|
1416
|
-
</span><span class="marked0"><a name="line816"></a> 816
|
1417
|
-
</span><span class="
|
1418
|
-
</span><span class="marked0"><a name="line818"></a> 818
|
1419
|
-
</span><span class="marked1"><a name="line819"></a> 819
|
1420
|
-
</span><span class="marked0"><a name="line820"></a> 820
|
1421
|
-
</span><span class="marked1"><a name="line821"></a> 821
|
1422
|
-
</span><span class="
|
1423
|
-
</span><span class="marked1"><a name="line823"></a> 823
|
1424
|
-
</span><span class="marked0"><a name="line824"></a> 824
|
1425
|
-
</span><span class="
|
1426
|
-
</span><span class="marked0"><a name="line826"></a> 826
|
1427
|
-
</span><span class="
|
1428
|
-
</span><span class="marked0"><a name="line828"></a> 828
|
1429
|
-
</span><span class="
|
1430
|
-
</span><span class="inferred0"><a name="line830"></a> 830
|
1431
|
-
</span><span class="marked1"><a name="line831"></a> 831
|
1432
|
-
</span><span class="
|
1433
|
-
</span><span class="inferred1"><a name="line833"></a> 833
|
1434
|
-
</span><span class="marked0"><a name="line834"></a> 834
|
1435
|
-
</span><span class="marked1"><a name="line835"></a> 835
|
1436
|
-
</span><span class="
|
1437
|
-
</span><span class="
|
1438
|
-
</span><span class="
|
1439
|
-
</span><span class="
|
1440
|
-
</span><span class="inferred0"><a name="line840"></a> 840
|
1441
|
-
</span><span class="
|
1442
|
-
</span><span class="
|
1443
|
-
</span><span class="inferred1"><a name="line843"></a> 843
|
1444
|
-
</span><span class="marked0"><a name="line844"></a> 844
|
1445
|
-
</span><span class="
|
1446
|
-
</span><span class="inferred0"><a name="line846"></a> 846
|
1447
|
-
</span><span class="
|
1448
|
-
</span><span class="inferred0"><a name="line848"></a> 848
|
1449
|
-
</span><span class="
|
1450
|
-
</span><span class="
|
1451
|
-
</span><span class="inferred1"><a name="line851"></a> 851
|
1452
|
-
</span><span class="
|
1453
|
-
</span><span class="marked1"><a name="line853"></a> 853
|
1454
|
-
</span><span class="inferred0"><a name="line854"></a> 854
|
1455
|
-
</span><span class="
|
1456
|
-
</span><span class="
|
1457
|
-
</span><span class="
|
1458
|
-
</span><span class="marked0"><a name="line858"></a> 858
|
1459
|
-
</span><span class="
|
1460
|
-
</span><span class="marked0"><a name="line860"></a> 860
|
1461
|
-
</span><span class="
|
1462
|
-
</span><span class="marked0"><a name="line862"></a> 862
|
1463
|
-
</span><span class="
|
1464
|
-
</span><span class="
|
1465
|
-
</span><span class="
|
1466
|
-
</span><span class="
|
1467
|
-
</span><span class="
|
1468
|
-
</span><span class="inferred0"><a name="line868"></a> 868
|
1469
|
-
</span><span class="
|
1470
|
-
</span><span class="inferred0"><a name="line870"></a> 870
|
1471
|
-
</span><span class="inferred1"><a name="line871"></a> 871
|
1472
|
-
</span><span class="inferred0"><a name="line872"></a> 872
|
1473
|
-
</span><span class="inferred1"><a name="line873"></a> 873
|
1474
|
-
</span><span class="inferred0"><a name="line874"></a> 874
|
1475
|
-
</span><span class="
|
1476
|
-
</span><span class="inferred0"><a name="line876"></a> 876
|
1477
|
-
</span><span class="inferred1"><a name="line877"></a> 877
|
1478
|
-
</span><span class="
|
1479
|
-
</span><span class="
|
1480
|
-
</span><span class="
|
1481
|
-
</span><span class="
|
1482
|
-
</span><span class="marked0"><a name="line882"></a> 882
|
1483
|
-
</span><span class="
|
1484
|
-
</span><span class="
|
1485
|
-
</span><span class="marked1"><a name="line885"></a> 885
|
1486
|
-
</span><span class="
|
1487
|
-
</span><span class="
|
1488
|
-
</span><span class="marked0"><a name="line888"></a> 888
|
1489
|
-
</span><span class="
|
1490
|
-
</span><span class="
|
1491
|
-
</span><span class="
|
1492
|
-
</span><span class="inferred0"><a name="line892"></a> 892
|
1493
|
-
</span><span class="
|
1494
|
-
</span><span class="
|
1495
|
-
</span><span class="
|
1496
|
-
</span><span class="marked0"><a name="line896"></a> 896
|
1497
|
-
</span><span class="marked1"><a name="line897"></a> 897
|
1498
|
-
</span><span class="
|
1499
|
-
</span><span class="marked1"><a name="line899"></a> 899 if
|
1500
|
-
</span><span class="marked0"><a name="line900"></a> 900 raise ArgumentError, "Expected absolute URI, got: #{
|
1395
|
+
</span><span class="marked1"><a name="line795"></a> 795 if uri.to_s == ""
|
1396
|
+
</span><span class="marked0"><a name="line796"></a> 796 return self.dup
|
1397
|
+
</span><span class="inferred1"><a name="line797"></a> 797 end
|
1398
|
+
</span><span class="inferred0"><a name="line798"></a> 798
|
1399
|
+
</span><span class="marked1"><a name="line799"></a> 799 joined_scheme = nil
|
1400
|
+
</span><span class="marked0"><a name="line800"></a> 800 joined_user = nil
|
1401
|
+
</span><span class="marked1"><a name="line801"></a> 801 joined_password = nil
|
1402
|
+
</span><span class="marked0"><a name="line802"></a> 802 joined_host = nil
|
1403
|
+
</span><span class="marked1"><a name="line803"></a> 803 joined_port = nil
|
1404
|
+
</span><span class="marked0"><a name="line804"></a> 804 joined_path = nil
|
1405
|
+
</span><span class="marked1"><a name="line805"></a> 805 joined_query = nil
|
1406
|
+
</span><span class="marked0"><a name="line806"></a> 806 joined_fragment = nil
|
1407
|
+
</span><span class="inferred1"><a name="line807"></a> 807
|
1408
|
+
</span><span class="inferred0"><a name="line808"></a> 808 # Section 5.2.2 of RFC 3986
|
1409
|
+
</span><span class="marked1"><a name="line809"></a> 809 if uri.scheme != nil
|
1410
|
+
</span><span class="marked0"><a name="line810"></a> 810 joined_scheme = uri.scheme
|
1411
|
+
</span><span class="marked1"><a name="line811"></a> 811 joined_user = uri.user
|
1412
|
+
</span><span class="marked0"><a name="line812"></a> 812 joined_password = uri.password
|
1413
|
+
</span><span class="marked1"><a name="line813"></a> 813 joined_host = uri.host
|
1414
|
+
</span><span class="marked0"><a name="line814"></a> 814 joined_port = uri.specified_port
|
1415
|
+
</span><span class="marked1"><a name="line815"></a> 815 joined_path = self.class.normalize_path(uri.path)
|
1416
|
+
</span><span class="marked0"><a name="line816"></a> 816 joined_query = uri.query
|
1417
|
+
</span><span class="inferred1"><a name="line817"></a> 817 else
|
1418
|
+
</span><span class="marked0"><a name="line818"></a> 818 if uri.authority != nil
|
1419
|
+
</span><span class="marked1"><a name="line819"></a> 819 joined_user = uri.user
|
1420
|
+
</span><span class="marked0"><a name="line820"></a> 820 joined_password = uri.password
|
1421
|
+
</span><span class="marked1"><a name="line821"></a> 821 joined_host = uri.host
|
1422
|
+
</span><span class="marked0"><a name="line822"></a> 822 joined_port = uri.specified_port
|
1423
|
+
</span><span class="marked1"><a name="line823"></a> 823 joined_path = self.class.normalize_path(uri.path)
|
1424
|
+
</span><span class="marked0"><a name="line824"></a> 824 joined_query = uri.query
|
1425
|
+
</span><span class="inferred1"><a name="line825"></a> 825 else
|
1426
|
+
</span><span class="marked0"><a name="line826"></a> 826 if uri.path == nil || uri.path == ""
|
1427
|
+
</span><span class="marked1"><a name="line827"></a> 827 joined_path = self.path
|
1428
|
+
</span><span class="marked0"><a name="line828"></a> 828 if uri.query != nil
|
1429
|
+
</span><span class="marked1"><a name="line829"></a> 829 joined_query = uri.query
|
1430
|
+
</span><span class="inferred0"><a name="line830"></a> 830 else
|
1431
|
+
</span><span class="marked1"><a name="line831"></a> 831 joined_query = self.query
|
1432
|
+
</span><span class="inferred0"><a name="line832"></a> 832 end
|
1433
|
+
</span><span class="inferred1"><a name="line833"></a> 833 else
|
1434
|
+
</span><span class="marked0"><a name="line834"></a> 834 if uri.path[0..0] == "/"
|
1435
|
+
</span><span class="marked1"><a name="line835"></a> 835 joined_path = self.class.normalize_path(uri.path)
|
1436
|
+
</span><span class="inferred0"><a name="line836"></a> 836 else
|
1437
|
+
</span><span class="marked1"><a name="line837"></a> 837 base_path = self.path.dup
|
1438
|
+
</span><span class="marked0"><a name="line838"></a> 838 base_path = "" if base_path == nil
|
1439
|
+
</span><span class="marked1"><a name="line839"></a> 839 base_path = self.class.normalize_path(base_path)
|
1440
|
+
</span><span class="inferred0"><a name="line840"></a> 840
|
1441
|
+
</span><span class="inferred1"><a name="line841"></a> 841 # Section 5.2.3 of RFC 3986
|
1442
|
+
</span><span class="inferred0"><a name="line842"></a> 842 #
|
1443
|
+
</span><span class="inferred1"><a name="line843"></a> 843 # Removes the right-most path segment from the base path.
|
1444
|
+
</span><span class="marked0"><a name="line844"></a> 844 if base_path =~ /\//
|
1445
|
+
</span><span class="marked1"><a name="line845"></a> 845 base_path.gsub!(/\/[^\/]+$/, "/")
|
1446
|
+
</span><span class="inferred0"><a name="line846"></a> 846 else
|
1447
|
+
</span><span class="marked1"><a name="line847"></a> 847 base_path = ""
|
1448
|
+
</span><span class="inferred0"><a name="line848"></a> 848 end
|
1449
|
+
</span><span class="inferred1"><a name="line849"></a> 849
|
1450
|
+
</span><span class="inferred0"><a name="line850"></a> 850 # If the base path is empty and an authority segment has been
|
1451
|
+
</span><span class="inferred1"><a name="line851"></a> 851 # defined, use a base path of "/"
|
1452
|
+
</span><span class="marked0"><a name="line852"></a> 852 if base_path == "" && self.authority != nil
|
1453
|
+
</span><span class="marked1"><a name="line853"></a> 853 base_path = "/"
|
1454
|
+
</span><span class="inferred0"><a name="line854"></a> 854 end
|
1455
|
+
</span><span class="inferred1"><a name="line855"></a> 855
|
1456
|
+
</span><span class="marked0"><a name="line856"></a> 856 joined_path = self.class.normalize_path(base_path + uri.path)
|
1457
|
+
</span><span class="inferred1"><a name="line857"></a> 857 end
|
1458
|
+
</span><span class="marked0"><a name="line858"></a> 858 joined_query = uri.query
|
1459
|
+
</span><span class="inferred1"><a name="line859"></a> 859 end
|
1460
|
+
</span><span class="marked0"><a name="line860"></a> 860 joined_user = self.user
|
1461
|
+
</span><span class="marked1"><a name="line861"></a> 861 joined_password = self.password
|
1462
|
+
</span><span class="marked0"><a name="line862"></a> 862 joined_host = self.host
|
1463
|
+
</span><span class="marked1"><a name="line863"></a> 863 joined_port = self.specified_port
|
1464
|
+
</span><span class="inferred0"><a name="line864"></a> 864 end
|
1465
|
+
</span><span class="marked1"><a name="line865"></a> 865 joined_scheme = self.scheme
|
1466
|
+
</span><span class="inferred0"><a name="line866"></a> 866 end
|
1467
|
+
</span><span class="marked1"><a name="line867"></a> 867 joined_fragment = uri.fragment
|
1468
|
+
</span><span class="inferred0"><a name="line868"></a> 868
|
1469
|
+
</span><span class="marked1"><a name="line869"></a> 869 return Addressable::URI.new(
|
1470
|
+
</span><span class="inferred0"><a name="line870"></a> 870 joined_scheme,
|
1471
|
+
</span><span class="inferred1"><a name="line871"></a> 871 joined_user,
|
1472
|
+
</span><span class="inferred0"><a name="line872"></a> 872 joined_password,
|
1473
|
+
</span><span class="inferred1"><a name="line873"></a> 873 joined_host,
|
1474
|
+
</span><span class="inferred0"><a name="line874"></a> 874 joined_port,
|
1475
|
+
</span><span class="inferred1"><a name="line875"></a> 875 joined_path,
|
1476
|
+
</span><span class="inferred0"><a name="line876"></a> 876 joined_query,
|
1477
|
+
</span><span class="inferred1"><a name="line877"></a> 877 joined_fragment
|
1478
|
+
</span><span class="marked0"><a name="line878"></a> 878 )
|
1479
|
+
</span><span class="inferred1"><a name="line879"></a> 879 end
|
1480
|
+
</span><span class="inferred0"><a name="line880"></a> 880
|
1481
|
+
</span><span class="inferred1"><a name="line881"></a> 881 # Merges two URIs together.
|
1482
|
+
</span><span class="marked0"><a name="line882"></a> 882 def merge(uri)
|
1483
|
+
</span><span class="marked1"><a name="line883"></a> 883 return self + uri
|
1484
|
+
</span><span class="marked0"><a name="line884"></a> 884 end
|
1485
|
+
</span><span class="marked1"><a name="line885"></a> 885 alias_method :join, :merge
|
1486
|
+
</span><span class="inferred0"><a name="line886"></a> 886
|
1487
|
+
</span><span class="inferred1"><a name="line887"></a> 887 # Destructive form of merge.
|
1488
|
+
</span><span class="marked0"><a name="line888"></a> 888 def merge!(uri)
|
1489
|
+
</span><span class="marked1"><a name="line889"></a> 889 replace_self(self.merge(uri))
|
1490
|
+
</span><span class="marked0"><a name="line890"></a> 890 end
|
1491
|
+
</span><span class="marked1"><a name="line891"></a> 891 alias_method :join!, :merge!
|
1492
|
+
</span><span class="inferred0"><a name="line892"></a> 892
|
1493
|
+
</span><span class="inferred1"><a name="line893"></a> 893 # Returns the shortest normalized relative form of this URI that uses the
|
1494
|
+
</span><span class="inferred0"><a name="line894"></a> 894 # supplied URI as a base for resolution. Returns an absolute URI if
|
1495
|
+
</span><span class="inferred1"><a name="line895"></a> 895 # necessary.
|
1496
|
+
</span><span class="marked0"><a name="line896"></a> 896 def route_from(uri)
|
1497
|
+
</span><span class="marked1"><a name="line897"></a> 897 uri = self.class.parse(uri).normalize
|
1498
|
+
</span><span class="marked0"><a name="line898"></a> 898 normalized_self = self.normalize
|
1499
|
+
</span><span class="marked1"><a name="line899"></a> 899 if normalized_self.relative?
|
1500
|
+
</span><span class="marked0"><a name="line900"></a> 900 raise ArgumentError, "Expected absolute URI, got: #{self.to_s}"
|
1501
1501
|
</span><span class="inferred1"><a name="line901"></a> 901 end
|
1502
|
-
</span><span class="marked0"><a name="line902"></a> 902 if
|
1503
|
-
</span><span class="marked1"><a name="line903"></a> 903
|
1502
|
+
</span><span class="marked0"><a name="line902"></a> 902 if uri.relative?
|
1503
|
+
</span><span class="marked1"><a name="line903"></a> 903 raise ArgumentError, "Expected absolute URI, got: #{uri.to_s}"
|
1504
1504
|
</span><span class="inferred0"><a name="line904"></a> 904 end
|
1505
|
-
</span><span class="marked1"><a name="line905"></a> 905
|
1506
|
-
</span><span class="marked0"><a name="line906"></a> 906
|
1507
|
-
</span><span class="
|
1508
|
-
</span><span class="marked0"><a name="line908"></a> 908
|
1509
|
-
</span><span class="marked1"><a name="line909"></a> 909
|
1510
|
-
</span><span class="marked0"><a name="line910"></a> 910
|
1511
|
-
</span><span class="marked1"><a name="line911"></a> 911
|
1512
|
-
</span><span class="marked0"><a name="line912"></a> 912 segments[:
|
1513
|
-
</span><span class="marked1"><a name="line913"></a> 913
|
1514
|
-
</span><span class="marked0"><a name="line914"></a> 914
|
1515
|
-
</span><span class="marked1"><a name="line915"></a> 915
|
1516
|
-
</span><span class="marked0"><a name="line916"></a> 916
|
1517
|
-
</span><span class="
|
1518
|
-
</span><span class="
|
1519
|
-
</span><span class="marked1"><a name="line919"></a> 919
|
1520
|
-
</span><span class="
|
1521
|
-
</span><span class="
|
1522
|
-
</span><span class="
|
1523
|
-
</span><span class="
|
1524
|
-
</span><span class="
|
1525
|
-
</span><span class="inferred1"><a name="line925"></a> 925
|
1526
|
-
</span><span class="inferred0"><a name="line926"></a> 926
|
1527
|
-
</span><span class="
|
1528
|
-
</span><span class="
|
1529
|
-
</span><span class="inferred1"><a name="line929"></a> 929
|
1530
|
-
</span><span class="marked0"><a name="line930"></a> 930
|
1531
|
-
</span><span class="
|
1532
|
-
</span><span class="inferred0"><a name="line932"></a> 932
|
1533
|
-
</span><span class="
|
1534
|
-
</span><span class="inferred0"><a name="line934"></a> 934 segments[:
|
1535
|
-
</span><span class="inferred1"><a name="line935"></a> 935 segments[:
|
1536
|
-
</span><span class="inferred0"><a name="line936"></a> 936 segments[:
|
1537
|
-
</span><span class="inferred1"><a name="line937"></a> 937 segments[:
|
1538
|
-
</span><span class="inferred0"><a name="line938"></a> 938 segments[:
|
1539
|
-
</span><span class="
|
1540
|
-
</span><span class="inferred0"><a name="line940"></a> 940
|
1541
|
-
</span><span class="inferred1"><a name="line941"></a> 941
|
1542
|
-
</span><span class="
|
1543
|
-
</span><span class="inferred1"><a name="line943"></a> 943
|
1544
|
-
</span><span class="inferred0"><a name="line944"></a> 944
|
1545
|
-
</span><span class="
|
1546
|
-
</span><span class="
|
1547
|
-
</span><span class="
|
1548
|
-
</span><span class="
|
1549
|
-
</span><span class="
|
1550
|
-
</span><span class="
|
1551
|
-
</span><span class="inferred1"><a name="line951"></a> 951
|
1552
|
-
</span><span class="inferred0"><a name="line952"></a> 952 #
|
1553
|
-
</span><span class="inferred1"><a name="line953"></a> 953 #
|
1554
|
-
</span><span class="inferred0"><a name="line954"></a> 954 #
|
1555
|
-
</span><span class="inferred1"><a name="line955"></a> 955 #
|
1556
|
-
</span><span class="
|
1557
|
-
</span><span class="
|
1558
|
-
</span><span class="
|
1559
|
-
</span><span class="marked1"><a name="line959"></a> 959
|
1560
|
-
</span><span class="marked0"><a name="line960"></a> 960
|
1561
|
-
</span><span class="marked1"><a name="line961"></a> 961
|
1562
|
-
</span><span class="marked0"><a name="line962"></a> 962
|
1563
|
-
</span><span class="marked1"><a name="line963"></a> 963
|
1564
|
-
</span><span class="
|
1565
|
-
</span><span class="
|
1566
|
-
</span><span class="marked0"><a name="line966"></a> 966
|
1567
|
-
</span><span class="
|
1568
|
-
</span><span class="
|
1569
|
-
</span><span class="marked1"><a name="line969"></a> 969
|
1570
|
-
</span><span class="
|
1571
|
-
</span><span class="
|
1572
|
-
</span><span class="
|
1573
|
-
</span><span class="
|
1574
|
-
</span><span class="
|
1575
|
-
</span><span class="
|
1576
|
-
</span><span class="marked0"><a name="line976"></a> 976
|
1577
|
-
</span><span class="
|
1578
|
-
</span><span class="
|
1579
|
-
</span><span class="marked1"><a name="line979"></a> 979
|
1580
|
-
</span><span class="
|
1581
|
-
</span><span class="
|
1582
|
-
</span><span class="marked0"><a name="line982"></a> 982
|
1583
|
-
</span><span class="marked1"><a name="line983"></a> 983
|
1584
|
-
</span><span class="
|
1585
|
-
</span><span class="marked1"><a name="line985"></a> 985
|
1586
|
-
</span><span class="
|
1587
|
-
</span><span class="
|
1588
|
-
</span><span class="marked0"><a name="line988"></a> 988
|
1505
|
+
</span><span class="marked1"><a name="line905"></a> 905 if normalized_self == uri
|
1506
|
+
</span><span class="marked0"><a name="line906"></a> 906 return Addressable::URI.parse("##{normalized_self.fragment}")
|
1507
|
+
</span><span class="inferred1"><a name="line907"></a> 907 end
|
1508
|
+
</span><span class="marked0"><a name="line908"></a> 908 segments = normalized_self.to_hash
|
1509
|
+
</span><span class="marked1"><a name="line909"></a> 909 if normalized_self.scheme == uri.scheme
|
1510
|
+
</span><span class="marked0"><a name="line910"></a> 910 segments[:scheme] = nil
|
1511
|
+
</span><span class="marked1"><a name="line911"></a> 911 if normalized_self.authority == uri.authority
|
1512
|
+
</span><span class="marked0"><a name="line912"></a> 912 segments[:user] = nil
|
1513
|
+
</span><span class="marked1"><a name="line913"></a> 913 segments[:password] = nil
|
1514
|
+
</span><span class="marked0"><a name="line914"></a> 914 segments[:host] = nil
|
1515
|
+
</span><span class="marked1"><a name="line915"></a> 915 segments[:port] = nil
|
1516
|
+
</span><span class="marked0"><a name="line916"></a> 916 if normalized_self.path == uri.path
|
1517
|
+
</span><span class="marked1"><a name="line917"></a> 917 segments[:path] = nil
|
1518
|
+
</span><span class="marked0"><a name="line918"></a> 918 if normalized_self.query == uri.query
|
1519
|
+
</span><span class="marked1"><a name="line919"></a> 919 segments[:query] = nil
|
1520
|
+
</span><span class="inferred0"><a name="line920"></a> 920 end
|
1521
|
+
</span><span class="inferred1"><a name="line921"></a> 921 else
|
1522
|
+
</span><span class="marked0"><a name="line922"></a> 922 if uri.path != "/"
|
1523
|
+
</span><span class="marked1"><a name="line923"></a> 923 segments[:path].gsub!(
|
1524
|
+
</span><span class="marked0"><a name="line924"></a> 924 Regexp.new("^" + Regexp.escape(uri.path)), "")
|
1525
|
+
</span><span class="inferred1"><a name="line925"></a> 925 end
|
1526
|
+
</span><span class="inferred0"><a name="line926"></a> 926 end
|
1527
|
+
</span><span class="inferred1"><a name="line927"></a> 927 end
|
1528
|
+
</span><span class="inferred0"><a name="line928"></a> 928 end
|
1529
|
+
</span><span class="inferred1"><a name="line929"></a> 929 # Avoid network-path references.
|
1530
|
+
</span><span class="marked0"><a name="line930"></a> 930 if segments[:host] != nil
|
1531
|
+
</span><span class="marked1"><a name="line931"></a> 931 segments[:scheme] = normalized_self.scheme
|
1532
|
+
</span><span class="inferred0"><a name="line932"></a> 932 end
|
1533
|
+
</span><span class="marked1"><a name="line933"></a> 933 return Addressable::URI.new(
|
1534
|
+
</span><span class="inferred0"><a name="line934"></a> 934 segments[:scheme],
|
1535
|
+
</span><span class="inferred1"><a name="line935"></a> 935 segments[:user],
|
1536
|
+
</span><span class="inferred0"><a name="line936"></a> 936 segments[:password],
|
1537
|
+
</span><span class="inferred1"><a name="line937"></a> 937 segments[:host],
|
1538
|
+
</span><span class="inferred0"><a name="line938"></a> 938 segments[:port],
|
1539
|
+
</span><span class="inferred1"><a name="line939"></a> 939 segments[:path],
|
1540
|
+
</span><span class="inferred0"><a name="line940"></a> 940 segments[:query],
|
1541
|
+
</span><span class="inferred1"><a name="line941"></a> 941 segments[:fragment]
|
1542
|
+
</span><span class="marked0"><a name="line942"></a> 942 )
|
1543
|
+
</span><span class="inferred1"><a name="line943"></a> 943 end
|
1544
|
+
</span><span class="inferred0"><a name="line944"></a> 944
|
1545
|
+
</span><span class="inferred1"><a name="line945"></a> 945 # Returns the shortest normalized relative form of the supplied URI that
|
1546
|
+
</span><span class="inferred0"><a name="line946"></a> 946 # uses this URI as a base for resolution. Returns an absolute URI if
|
1547
|
+
</span><span class="inferred1"><a name="line947"></a> 947 # necessary.
|
1548
|
+
</span><span class="marked0"><a name="line948"></a> 948 def route_to(uri)
|
1549
|
+
</span><span class="marked1"><a name="line949"></a> 949 return self.class.parse(uri).route_from(self)
|
1550
|
+
</span><span class="marked0"><a name="line950"></a> 950 end
|
1551
|
+
</span><span class="inferred1"><a name="line951"></a> 951
|
1552
|
+
</span><span class="inferred0"><a name="line952"></a> 952 # Returns a normalized URI object.
|
1553
|
+
</span><span class="inferred1"><a name="line953"></a> 953 #
|
1554
|
+
</span><span class="inferred0"><a name="line954"></a> 954 # NOTE: This method does not attempt to fully conform to specifications.
|
1555
|
+
</span><span class="inferred1"><a name="line955"></a> 955 # It exists largely to correct other people's failures to read the
|
1556
|
+
</span><span class="inferred0"><a name="line956"></a> 956 # specifications, and also to deal with caching issues since several
|
1557
|
+
</span><span class="inferred1"><a name="line957"></a> 957 # different URIs may represent the same resource and should not be
|
1558
|
+
</span><span class="inferred0"><a name="line958"></a> 958 # cached multiple times.
|
1559
|
+
</span><span class="marked1"><a name="line959"></a> 959 def normalize
|
1560
|
+
</span><span class="marked0"><a name="line960"></a> 960 normalized_scheme = nil
|
1561
|
+
</span><span class="marked1"><a name="line961"></a> 961 normalized_scheme = self.scheme.strip.downcase if self.scheme != nil
|
1562
|
+
</span><span class="marked0"><a name="line962"></a> 962 normalized_scheme = "svn+ssh" if normalized_scheme == "ssh+svn"
|
1563
|
+
</span><span class="marked1"><a name="line963"></a> 963 if normalized_scheme == "feed"
|
1564
|
+
</span><span class="marked0"><a name="line964"></a> 964 if self.to_s =~ /^feed:\/*http:\/*/
|
1565
|
+
</span><span class="marked1"><a name="line965"></a> 965 return self.class.parse(
|
1566
|
+
</span><span class="marked0"><a name="line966"></a> 966 self.to_s.scan(/^feed:\/*(http:\/*.*)/).flatten[0]).normalize
|
1567
|
+
</span><span class="inferred1"><a name="line967"></a> 967 end
|
1568
|
+
</span><span class="inferred0"><a name="line968"></a> 968 end
|
1569
|
+
</span><span class="marked1"><a name="line969"></a> 969 normalized_user = nil
|
1570
|
+
</span><span class="marked0"><a name="line970"></a> 970 normalized_user = self.user.strip if self.user != nil
|
1571
|
+
</span><span class="marked1"><a name="line971"></a> 971 normalized_password = nil
|
1572
|
+
</span><span class="marked0"><a name="line972"></a> 972 normalized_password = self.password.strip if self.password != nil
|
1573
|
+
</span><span class="inferred1"><a name="line973"></a> 973
|
1574
|
+
</span><span class="inferred0"><a name="line974"></a> 974 # If we are using http or https and user/password are blank,
|
1575
|
+
</span><span class="inferred1"><a name="line975"></a> 975 # then we remove them
|
1576
|
+
</span><span class="marked0"><a name="line976"></a> 976 if normalized_scheme =~ /https?/ && normalized_user == "" &&
|
1577
|
+
</span><span class="marked1"><a name="line977"></a> 977 (!normalized_password || normalized_password == "")
|
1578
|
+
</span><span class="marked0"><a name="line978"></a> 978 normalized_user = nil
|
1579
|
+
</span><span class="marked1"><a name="line979"></a> 979 normalized_password = nil
|
1580
|
+
</span><span class="inferred0"><a name="line980"></a> 980 end
|
1581
|
+
</span><span class="inferred1"><a name="line981"></a> 981
|
1582
|
+
</span><span class="marked0"><a name="line982"></a> 982 normalized_host = nil
|
1583
|
+
</span><span class="marked1"><a name="line983"></a> 983 normalized_host = self.host.strip.downcase if self.host != nil
|
1584
|
+
</span><span class="marked0"><a name="line984"></a> 984 if normalized_host != nil
|
1585
|
+
</span><span class="marked1"><a name="line985"></a> 985 begin
|
1586
|
+
</span><span class="marked0"><a name="line986"></a> 986 normalized_host = URI::IDNA.to_ascii(normalized_host)
|
1587
|
+
</span><span class="inferred1"><a name="line987"></a> 987 rescue Exception
|
1588
|
+
</span><span class="marked0"><a name="line988"></a> 988 nil
|
1589
1589
|
</span><span class="inferred1"><a name="line989"></a> 989 end
|
1590
|
-
</span><span class="
|
1591
|
-
</span><span class="
|
1592
|
-
</span><span class="
|
1593
|
-
</span><span class="
|
1594
|
-
</span><span class="
|
1595
|
-
</span><span class="
|
1596
|
-
</span><span class="marked0"><a name="line996"></a> 996
|
1597
|
-
</span><span class="marked1"><a name="line997"></a> 997
|
1598
|
-
</span><span class="
|
1599
|
-
</span><span class="marked1"><a name="line999"></a> 999
|
1600
|
-
</span><span class="
|
1601
|
-
</span><span class="marked1"><a name="line1001"></a>1001 if normalized_path
|
1602
|
-
</span><span class="marked0"><a name="line1002"></a>1002
|
1603
|
-
</span><span class="
|
1604
|
-
</span><span class="
|
1605
|
-
</span><span class="
|
1606
|
-
</span><span class="
|
1607
|
-
</span><span class="
|
1608
|
-
</span><span class="
|
1590
|
+
</span><span class="marked0"><a name="line990"></a> 990 if normalized_host[-1..-1] == "."
|
1591
|
+
</span><span class="marked1"><a name="line991"></a> 991 normalized_host = normalized_host[0...-1]
|
1592
|
+
</span><span class="inferred0"><a name="line992"></a> 992 end
|
1593
|
+
</span><span class="inferred1"><a name="line993"></a> 993 end
|
1594
|
+
</span><span class="inferred0"><a name="line994"></a> 994
|
1595
|
+
</span><span class="marked1"><a name="line995"></a> 995 normalized_port = self.port
|
1596
|
+
</span><span class="marked0"><a name="line996"></a> 996 if self.class.scheme_mapping[normalized_scheme] == normalized_port
|
1597
|
+
</span><span class="marked1"><a name="line997"></a> 997 normalized_port = nil
|
1598
|
+
</span><span class="inferred0"><a name="line998"></a> 998 end
|
1599
|
+
</span><span class="marked1"><a name="line999"></a> 999 normalized_path = nil
|
1600
|
+
</span><span class="marked0"><a name="line1000"></a>1000 normalized_path = self.path.strip if self.path != nil
|
1601
|
+
</span><span class="marked1"><a name="line1001"></a>1001 if normalized_path != nil
|
1602
|
+
</span><span class="marked0"><a name="line1002"></a>1002 normalized_path = self.class.normalize_path(normalized_path)
|
1603
|
+
</span><span class="inferred1"><a name="line1003"></a>1003 end
|
1604
|
+
</span><span class="marked0"><a name="line1004"></a>1004 if normalized_path == ""
|
1605
|
+
</span><span class="marked1"><a name="line1005"></a>1005 if ["http", "https", "ftp", "tftp"].include?(normalized_scheme)
|
1606
|
+
</span><span class="marked0"><a name="line1006"></a>1006 normalized_path = "/"
|
1607
|
+
</span><span class="inferred1"><a name="line1007"></a>1007 end
|
1608
|
+
</span><span class="inferred0"><a name="line1008"></a>1008 end
|
1609
1609
|
</span><span class="inferred1"><a name="line1009"></a>1009
|
1610
|
-
</span><span class="marked0"><a name="line1010"></a>1010
|
1611
|
-
</span><span class="marked1"><a name="line1011"></a>1011
|
1612
|
-
</span><span class="
|
1613
|
-
</span><span class="marked1"><a name="line1013"></a>1013
|
1614
|
-
</span><span class="
|
1615
|
-
</span><span class="
|
1616
|
-
</span><span class="
|
1617
|
-
</span><span class="inferred1"><a name="line1017"></a>1017
|
1618
|
-
</span><span class="inferred0"><a name="line1018"></a>1018
|
1619
|
-
</span><span class="inferred1"><a name="line1019"></a>1019
|
1620
|
-
</span><span class="inferred0"><a name="line1020"></a>1020
|
1621
|
-
</span><span class="inferred1"><a name="line1021"></a>1021
|
1622
|
-
</span><span class="
|
1623
|
-
</span><span class="inferred1"><a name="line1023"></a>1023
|
1624
|
-
</span><span class="inferred0"><a name="line1024"></a>1024
|
1625
|
-
</span><span class="
|
1626
|
-
</span><span class="
|
1627
|
-
</span><span class="
|
1628
|
-
</span><span class="
|
1629
|
-
</span><span class="
|
1630
|
-
</span><span class="
|
1631
|
-
</span><span class="
|
1632
|
-
</span><span class="inferred0"><a name="line1032"></a>1032
|
1633
|
-
</span><span class="
|
1634
|
-
</span><span class="
|
1635
|
-
</span><span class="
|
1636
|
-
</span><span class="marked0"><a name="line1036"></a>1036
|
1637
|
-
</span><span class="marked1"><a name="line1037"></a>1037
|
1638
|
-
</span><span class="
|
1639
|
-
</span><span class="marked1"><a name="line1039"></a>1039
|
1640
|
-
</span><span class="
|
1641
|
-
</span><span class="
|
1642
|
-
</span><span class="
|
1643
|
-
</span><span class="inferred1"><a name="line1043"></a>1043
|
1644
|
-
</span><span class="
|
1645
|
-
</span><span class="inferred1"><a name="line1045"></a>1045
|
1646
|
-
</span><span class="inferred0"><a name="line1046"></a>1046
|
1647
|
-
</span><span class="
|
1648
|
-
</span><span class="
|
1649
|
-
</span><span class="
|
1650
|
-
</span><span class="
|
1651
|
-
</span><span class="marked1"><a name="line1051"></a>1051
|
1652
|
-
</span><span class="marked0"><a name="line1052"></a>1052
|
1653
|
-
</span><span class="inferred1"><a name="line1053"></a>1053
|
1654
|
-
</span><span class="marked0"><a name="line1054"></a>1054
|
1655
|
-
</span><span class="
|
1656
|
-
</span><span class="inferred0"><a name="line1056"></a>1056
|
1657
|
-
</span><span class="marked1"><a name="line1057"></a>1057
|
1658
|
-
</span><span class="inferred0"><a name="line1058"></a>1058
|
1659
|
-
</span><span class="inferred1"><a name="line1059"></a>1059
|
1660
|
-
</span><span class="
|
1661
|
-
</span><span class="inferred1"><a name="line1061"></a>1061
|
1662
|
-
</span><span class="
|
1663
|
-
</span><span class="
|
1664
|
-
</span><span class="
|
1665
|
-
</span><span class="
|
1666
|
-
</span><span class="
|
1667
|
-
</span><span class="
|
1668
|
-
</span><span class="inferred0"><a name="line1068"></a>1068
|
1669
|
-
</span><span class="
|
1670
|
-
</span><span class="
|
1671
|
-
</span><span class="
|
1672
|
-
</span><span class="
|
1673
|
-
</span><span class="
|
1674
|
-
</span><span class="
|
1675
|
-
</span><span class="inferred1"><a name="line1075"></a>1075
|
1676
|
-
</span><span class="
|
1677
|
-
</span><span class="
|
1678
|
-
</span><span class="
|
1679
|
-
</span><span class="
|
1680
|
-
</span><span class="
|
1681
|
-
</span><span class="marked1"><a name="line1081"></a>1081
|
1682
|
-
</span><span class="
|
1683
|
-
</span><span class="
|
1684
|
-
</span><span class="marked0"><a name="line1084"></a>1084
|
1685
|
-
</span><span class="marked1"><a name="line1085"></a>1085
|
1686
|
-
</span><span class="marked0"><a name="line1086"></a>1086
|
1687
|
-
</span><span class="marked1"><a name="line1087"></a>1087
|
1688
|
-
</span><span class="marked0"><a name="line1088"></a>1088
|
1689
|
-
</span><span class="marked1"><a name="line1089"></a>1089
|
1690
|
-
</span><span class="marked0"><a name="line1090"></a>1090
|
1691
|
-
</span><span class="
|
1692
|
-
</span><span class="
|
1693
|
-
</span><span class="
|
1694
|
-
</span><span class="inferred0"><a name="line1094"></a>1094
|
1695
|
-
</span><span class="inferred1"><a name="line1095"></a>1095
|
1696
|
-
</span><span class="inferred0"><a name="line1096"></a>1096
|
1697
|
-
</span><span class="inferred1"><a name="line1097"></a>1097
|
1698
|
-
</span><span class="inferred0"><a name="line1098"></a>1098
|
1699
|
-
</span><span class="inferred1"><a name="line1099"></a>1099
|
1700
|
-
</span><span class="
|
1701
|
-
</span><span class="inferred1"><a name="line1101"></a>1101
|
1702
|
-
</span><span class="inferred0"><a name="line1102"></a>1102
|
1703
|
-
</span><span class="
|
1704
|
-
</span><span class="
|
1705
|
-
</span><span class="
|
1706
|
-
</span><span class="
|
1707
|
-
</span><span class="marked1"><a name="line1107"></a>1107
|
1708
|
-
</span><span class="marked0"><a name="line1108"></a>1108 uri_string &
|
1709
|
-
</span><span class="marked1"><a name="line1109"></a>1109 uri_string << "
|
1710
|
-
</span><span class="marked0"><a name="line1110"></a>1110 uri_string << "
|
1711
|
-
</span><span class="marked1"><a name="line1111"></a>1111
|
1712
|
-
</span><span class="
|
1713
|
-
</span><span class="
|
1714
|
-
</span><span class="
|
1715
|
-
</span><span class="
|
1716
|
-
</span><span class="inferred0"><a name="line1116"></a>1116
|
1717
|
-
</span><span class="
|
1718
|
-
</span><span class="marked0"><a name="line1118"></a>1118
|
1719
|
-
</span><span class="
|
1720
|
-
</span><span class="marked0"><a name="line1120"></a>1120 :
|
1721
|
-
</span><span class="marked1"><a name="line1121"></a>1121 :
|
1722
|
-
</span><span class="marked0"><a name="line1122"></a>1122 :
|
1723
|
-
</span><span class="marked1"><a name="line1123"></a>1123 :
|
1724
|
-
</span><span class="marked0"><a name="line1124"></a>1124 :
|
1725
|
-
</span><span class="marked1"><a name="line1125"></a>1125
|
1726
|
-
</span><span class="marked0"><a name="line1126"></a>1126
|
1727
|
-
</span><span class="
|
1728
|
-
</span><span class="
|
1729
|
-
</span><span class="marked1"><a name="line1129"></a>1129
|
1730
|
-
</span><span class="
|
1731
|
-
</span><span class="
|
1732
|
-
</span><span class="
|
1733
|
-
</span><span class="
|
1734
|
-
</span><span class="
|
1735
|
-
</span><span class="inferred1"><a name="line1135"></a>1135
|
1736
|
-
</span><span class="inferred0"><a name="line1136"></a>1136 #
|
1737
|
-
</span><span class="
|
1738
|
-
</span><span class="inferred0"><a name="line1138"></a>1138
|
1739
|
-
</span><span class="
|
1740
|
-
</span><span class="marked0"><a name="line1140"></a>1140
|
1741
|
-
</span><span class="
|
1742
|
-
</span><span class="marked0"><a name="line1142"></a>1142
|
1743
|
-
</span><span class="
|
1744
|
-
</span><span class="marked0"><a name="line1144"></a>1144
|
1745
|
-
</span><span class="
|
1746
|
-
</span><span class="inferred0"><a name="line1146"></a>1146
|
1747
|
-
</span><span class="
|
1748
|
-
</span><span class="inferred0"><a name="line1148"></a>1148
|
1749
|
-
</span><span class="inferred1"><a name="line1149"></a>1149
|
1750
|
-
</span><span class="inferred0"><a name="line1150"></a>1150
|
1751
|
-
</span><span class="
|
1752
|
-
</span><span class="
|
1753
|
-
</span><span class="
|
1754
|
-
</span><span class="marked0"><a name="line1154"></a>1154
|
1755
|
-
</span><span class="
|
1756
|
-
</span><span class="marked0"><a name="line1156"></a>1156
|
1757
|
-
</span><span class="
|
1758
|
-
</span><span class="inferred0"><a name="line1158"></a>1158
|
1759
|
-
</span><span class="
|
1760
|
-
</span><span class="inferred0"><a name="line1160"></a>1160
|
1761
|
-
</span><span class="inferred1"><a name="line1161"></a>1161
|
1762
|
-
</span><span class="
|
1763
|
-
</span><span class="inferred1"><a name="line1163"></a>1163
|
1764
|
-
</span><span class="
|
1765
|
-
</span><span class="marked1"><a name="line1165"></a>1165
|
1766
|
-
</span><span class="
|
1767
|
-
</span><span class="marked1"><a name="line1167"></a>1167
|
1768
|
-
</span><span class="
|
1769
|
-
</span><span class="marked1"><a name="line1169"></a>1169
|
1770
|
-
</span><span class="
|
1771
|
-
</span><span class="
|
1772
|
-
</span><span class="marked0"><a name="line1172"></a>1172
|
1773
|
-
</span><span class="inferred1"><a name="line1173"></a>1173
|
1774
|
-
</span><span class="marked0"><a name="line1174"></a>1174
|
1775
|
-
</span><span class="
|
1776
|
-
</span><span class="
|
1777
|
-
</span><span class="
|
1778
|
-
</span><span class="
|
1779
|
-
</span><span class="
|
1780
|
-
</span><span class="inferred0"><a name="line1180"></a>1180
|
1781
|
-
</span><span class="
|
1782
|
-
</span><span class="
|
1783
|
-
</span><span class="inferred1"><a name="line1183"></a>1183
|
1784
|
-
</span><span class="
|
1785
|
-
</span><span class="
|
1786
|
-
</span><span class="inferred0"><a name="line1186"></a>1186
|
1787
|
-
</span><span class="marked1"><a name="line1187"></a>1187
|
1788
|
-
</span><span class="
|
1789
|
-
</span><span class="
|
1790
|
-
</span><span class="
|
1791
|
-
</span><span class="marked1"><a name="line1191"></a>1191
|
1792
|
-
</span><span class="marked0"><a name="line1192"></a>1192
|
1793
|
-
</span><span class="
|
1794
|
-
</span><span class="marked0"><a name="line1194"></a>1194
|
1795
|
-
</span><span class="marked1"><a name="line1195"></a>1195
|
1796
|
-
</span><span class="marked0"><a name="line1196"></a>1196
|
1797
|
-
</span><span class="
|
1798
|
-
</span><span class="marked0"><a name="line1198"></a>1198 parent
|
1799
|
-
</span><span class="marked1"><a name="line1199"></a>1199
|
1800
|
-
</span><span class="
|
1801
|
-
</span><span class="
|
1802
|
-
</span><span class="marked0"><a name="line1202"></a>1202
|
1803
|
-
</span><span class="marked1"><a name="line1203"></a>1203
|
1804
|
-
</span><span class="
|
1805
|
-
</span><span class="marked1"><a name="line1205"></a>1205
|
1806
|
-
</span><span class="
|
1807
|
-
</span><span class="
|
1808
|
-
</span><span class="
|
1809
|
-
</span><span class="
|
1810
|
-
</span><span class="
|
1811
|
-
</span><span class="
|
1812
|
-
</span><span class="marked0"><a name="line1212"></a>1212
|
1813
|
-
</span><span class="marked1"><a name="line1213"></a>1213
|
1814
|
-
</span><span class="
|
1815
|
-
</span><span class="
|
1816
|
-
</span><span class="marked0"><a name="line1216"></a>1216
|
1817
|
-
</span><span class="
|
1818
|
-
</span><span class="
|
1819
|
-
</span><span class="marked1"><a name="line1219"></a>1219
|
1820
|
-
</span><span class="marked0"><a name="line1220"></a>1220
|
1821
|
-
</span><span class="
|
1822
|
-
</span><span class="
|
1823
|
-
</span><span class="
|
1824
|
-
</span><span class="inferred0"><a name="line1224"></a>1224
|
1825
|
-
</span><span class="inferred1"><a name="line1225"></a>1225
|
1826
|
-
</span><span class="inferred0"><a name="line1226"></a>1226
|
1827
|
-
</span><span class="
|
1828
|
-
</span><span class="inferred0"><a name="line1228"></a>1228
|
1829
|
-
</span><span class="
|
1830
|
-
</span><span class="marked0"><a name="line1230"></a>1230
|
1831
|
-
</span><span class="inferred1"><a name="line1231"></a>1231
|
1832
|
-
</span><span class="marked0"><a name="line1232"></a>1232 @
|
1833
|
-
</span><span class="marked1"><a name="line1233"></a>1233 @
|
1834
|
-
</span><span class="
|
1835
|
-
</span><span class="marked1"><a name="line1235"></a>1235 @
|
1836
|
-
</span><span class="marked0"><a name="line1236"></a>1236 @
|
1837
|
-
</span><span class="marked1"><a name="line1237"></a>1237 @
|
1838
|
-
</span><span class="marked0"><a name="line1238"></a>1238 @
|
1839
|
-
</span><span class="marked1"><a name="line1239"></a>1239 @
|
1840
|
-
</span><span class="marked0"><a name="line1240"></a>1240 @
|
1841
|
-
</span><span class="marked1"><a name="line1241"></a>1241
|
1842
|
-
</span><span class="
|
1843
|
-
</span><span class="
|
1844
|
-
</span><span class="
|
1610
|
+
</span><span class="marked0"><a name="line1010"></a>1010 normalized_query = nil
|
1611
|
+
</span><span class="marked1"><a name="line1011"></a>1011 normalized_query = self.query.strip if self.query != nil
|
1612
|
+
</span><span class="inferred0"><a name="line1012"></a>1012
|
1613
|
+
</span><span class="marked1"><a name="line1013"></a>1013 normalized_fragment = nil
|
1614
|
+
</span><span class="marked0"><a name="line1014"></a>1014 normalized_fragment = self.fragment.strip if self.fragment != nil
|
1615
|
+
</span><span class="marked1"><a name="line1015"></a>1015 return Addressable::URI.parse(
|
1616
|
+
</span><span class="marked0"><a name="line1016"></a>1016 Addressable::URI.normalized_encode(Addressable::URI.new(
|
1617
|
+
</span><span class="inferred1"><a name="line1017"></a>1017 normalized_scheme,
|
1618
|
+
</span><span class="inferred0"><a name="line1018"></a>1018 normalized_user,
|
1619
|
+
</span><span class="inferred1"><a name="line1019"></a>1019 normalized_password,
|
1620
|
+
</span><span class="inferred0"><a name="line1020"></a>1020 normalized_host,
|
1621
|
+
</span><span class="inferred1"><a name="line1021"></a>1021 normalized_port,
|
1622
|
+
</span><span class="inferred0"><a name="line1022"></a>1022 normalized_path,
|
1623
|
+
</span><span class="inferred1"><a name="line1023"></a>1023 normalized_query,
|
1624
|
+
</span><span class="inferred0"><a name="line1024"></a>1024 normalized_fragment
|
1625
|
+
</span><span class="marked1"><a name="line1025"></a>1025 )))
|
1626
|
+
</span><span class="inferred0"><a name="line1026"></a>1026 end
|
1627
|
+
</span><span class="inferred1"><a name="line1027"></a>1027
|
1628
|
+
</span><span class="inferred0"><a name="line1028"></a>1028 # Destructively normalizes this URI object.
|
1629
|
+
</span><span class="marked1"><a name="line1029"></a>1029 def normalize!
|
1630
|
+
</span><span class="marked0"><a name="line1030"></a>1030 replace_self(self.normalize)
|
1631
|
+
</span><span class="marked1"><a name="line1031"></a>1031 end
|
1632
|
+
</span><span class="inferred0"><a name="line1032"></a>1032
|
1633
|
+
</span><span class="inferred1"><a name="line1033"></a>1033 # Creates a URI suitable for display to users. If semantic attacks are
|
1634
|
+
</span><span class="inferred0"><a name="line1034"></a>1034 # likely, the application should try to detect these and warn the user.
|
1635
|
+
</span><span class="inferred1"><a name="line1035"></a>1035 # See RFC 3986 section 7.6 for more information.
|
1636
|
+
</span><span class="marked0"><a name="line1036"></a>1036 def display_uri
|
1637
|
+
</span><span class="marked1"><a name="line1037"></a>1037 display_uri = self.normalize
|
1638
|
+
</span><span class="marked0"><a name="line1038"></a>1038 begin
|
1639
|
+
</span><span class="marked1"><a name="line1039"></a>1039 display_uri.instance_variable_set("@host",
|
1640
|
+
</span><span class="marked0"><a name="line1040"></a>1040 URI::IDNA.to_unicode(display_uri.host))
|
1641
|
+
</span><span class="inferred1"><a name="line1041"></a>1041 rescue Exception
|
1642
|
+
</span><span class="marked0"><a name="line1042"></a>1042 nil
|
1643
|
+
</span><span class="inferred1"><a name="line1043"></a>1043 end
|
1644
|
+
</span><span class="marked0"><a name="line1044"></a>1044 return display_uri
|
1645
|
+
</span><span class="inferred1"><a name="line1045"></a>1045 end
|
1646
|
+
</span><span class="inferred0"><a name="line1046"></a>1046
|
1647
|
+
</span><span class="inferred1"><a name="line1047"></a>1047 # Returns true if the URI objects are equal. This method normalizes
|
1648
|
+
</span><span class="inferred0"><a name="line1048"></a>1048 # both URIs before doing the comparison, and allows comparison against
|
1649
|
+
</span><span class="inferred1"><a name="line1049"></a>1049 # strings.
|
1650
|
+
</span><span class="marked0"><a name="line1050"></a>1050 def ===(uri)
|
1651
|
+
</span><span class="marked1"><a name="line1051"></a>1051 if uri.respond_to?(:normalize)
|
1652
|
+
</span><span class="marked0"><a name="line1052"></a>1052 uri_string = uri.normalize.to_s
|
1653
|
+
</span><span class="inferred1"><a name="line1053"></a>1053 else
|
1654
|
+
</span><span class="marked0"><a name="line1054"></a>1054 begin
|
1655
|
+
</span><span class="marked1"><a name="line1055"></a>1055 uri_string = URI.parse(uri.to_s).normalize.to_s
|
1656
|
+
</span><span class="inferred0"><a name="line1056"></a>1056 rescue InvalidURIError
|
1657
|
+
</span><span class="marked1"><a name="line1057"></a>1057 return false
|
1658
|
+
</span><span class="inferred0"><a name="line1058"></a>1058 end
|
1659
|
+
</span><span class="inferred1"><a name="line1059"></a>1059 end
|
1660
|
+
</span><span class="marked0"><a name="line1060"></a>1060 return self.normalize.to_s == uri_string
|
1661
|
+
</span><span class="inferred1"><a name="line1061"></a>1061 end
|
1662
|
+
</span><span class="inferred0"><a name="line1062"></a>1062
|
1663
|
+
</span><span class="inferred1"><a name="line1063"></a>1063 # Returns true if the URI objects are equal. This method normalizes
|
1664
|
+
</span><span class="inferred0"><a name="line1064"></a>1064 # both URIs before doing the comparison.
|
1665
|
+
</span><span class="marked1"><a name="line1065"></a>1065 def ==(uri)
|
1666
|
+
</span><span class="marked0"><a name="line1066"></a>1066 return false unless uri.kind_of?(self.class)
|
1667
|
+
</span><span class="marked1"><a name="line1067"></a>1067 return self.normalize.to_s == uri.normalize.to_s
|
1668
|
+
</span><span class="inferred0"><a name="line1068"></a>1068 end
|
1669
|
+
</span><span class="inferred1"><a name="line1069"></a>1069
|
1670
|
+
</span><span class="inferred0"><a name="line1070"></a>1070 # Returns true if the URI objects are equal. This method does NOT
|
1671
|
+
</span><span class="inferred1"><a name="line1071"></a>1071 # normalize either URI before doing the comparison.
|
1672
|
+
</span><span class="marked0"><a name="line1072"></a>1072 def eql?(uri)
|
1673
|
+
</span><span class="marked1"><a name="line1073"></a>1073 return false unless uri.kind_of?(self.class)
|
1674
|
+
</span><span class="marked0"><a name="line1074"></a>1074 return self.to_s == uri.to_s
|
1675
|
+
</span><span class="inferred1"><a name="line1075"></a>1075 end
|
1676
|
+
</span><span class="inferred0"><a name="line1076"></a>1076
|
1677
|
+
</span><span class="inferred1"><a name="line1077"></a>1077 # Returns a hash value that will make a URI equivalent to its normalized
|
1678
|
+
</span><span class="inferred0"><a name="line1078"></a>1078 # form.
|
1679
|
+
</span><span class="marked1"><a name="line1079"></a>1079 def hash
|
1680
|
+
</span><span class="marked0"><a name="line1080"></a>1080 return (self.normalize.to_s.hash * -1)
|
1681
|
+
</span><span class="marked1"><a name="line1081"></a>1081 end
|
1682
|
+
</span><span class="inferred0"><a name="line1082"></a>1082
|
1683
|
+
</span><span class="inferred1"><a name="line1083"></a>1083 # Clones the URI object.
|
1684
|
+
</span><span class="marked0"><a name="line1084"></a>1084 def dup
|
1685
|
+
</span><span class="marked1"><a name="line1085"></a>1085 duplicated_scheme = self.scheme ? self.scheme.dup : nil
|
1686
|
+
</span><span class="marked0"><a name="line1086"></a>1086 duplicated_user = self.user ? self.user.dup : nil
|
1687
|
+
</span><span class="marked1"><a name="line1087"></a>1087 duplicated_password = self.password ? self.password.dup : nil
|
1688
|
+
</span><span class="marked0"><a name="line1088"></a>1088 duplicated_host = self.host ? self.host.dup : nil
|
1689
|
+
</span><span class="marked1"><a name="line1089"></a>1089 duplicated_port = self.specified_port
|
1690
|
+
</span><span class="marked0"><a name="line1090"></a>1090 duplicated_path = self.path ? self.path.dup : nil
|
1691
|
+
</span><span class="marked1"><a name="line1091"></a>1091 duplicated_query = self.query ? self.query.dup : nil
|
1692
|
+
</span><span class="marked0"><a name="line1092"></a>1092 duplicated_fragment = self.fragment ? self.fragment.dup : nil
|
1693
|
+
</span><span class="marked1"><a name="line1093"></a>1093 duplicated_uri = Addressable::URI.new(
|
1694
|
+
</span><span class="inferred0"><a name="line1094"></a>1094 duplicated_scheme,
|
1695
|
+
</span><span class="inferred1"><a name="line1095"></a>1095 duplicated_user,
|
1696
|
+
</span><span class="inferred0"><a name="line1096"></a>1096 duplicated_password,
|
1697
|
+
</span><span class="inferred1"><a name="line1097"></a>1097 duplicated_host,
|
1698
|
+
</span><span class="inferred0"><a name="line1098"></a>1098 duplicated_port,
|
1699
|
+
</span><span class="inferred1"><a name="line1099"></a>1099 duplicated_path,
|
1700
|
+
</span><span class="inferred0"><a name="line1100"></a>1100 duplicated_query,
|
1701
|
+
</span><span class="inferred1"><a name="line1101"></a>1101 duplicated_fragment
|
1702
|
+
</span><span class="inferred0"><a name="line1102"></a>1102 )
|
1703
|
+
</span><span class="marked1"><a name="line1103"></a>1103 return duplicated_uri
|
1704
|
+
</span><span class="inferred0"><a name="line1104"></a>1104 end
|
1705
|
+
</span><span class="inferred1"><a name="line1105"></a>1105
|
1706
|
+
</span><span class="inferred0"><a name="line1106"></a>1106 # Returns the assembled URI as a string.
|
1707
|
+
</span><span class="marked1"><a name="line1107"></a>1107 def to_s
|
1708
|
+
</span><span class="marked0"><a name="line1108"></a>1108 uri_string = ""
|
1709
|
+
</span><span class="marked1"><a name="line1109"></a>1109 uri_string << "#{self.scheme}:" if self.scheme != nil
|
1710
|
+
</span><span class="marked0"><a name="line1110"></a>1110 uri_string << "//#{self.authority}" if self.authority != nil
|
1711
|
+
</span><span class="marked1"><a name="line1111"></a>1111 uri_string << self.path.to_s
|
1712
|
+
</span><span class="marked0"><a name="line1112"></a>1112 uri_string << "?#{self.query}" if self.query != nil
|
1713
|
+
</span><span class="marked1"><a name="line1113"></a>1113 uri_string << "##{self.fragment}" if self.fragment != nil
|
1714
|
+
</span><span class="marked0"><a name="line1114"></a>1114 return uri_string
|
1715
|
+
</span><span class="inferred1"><a name="line1115"></a>1115 end
|
1716
|
+
</span><span class="inferred0"><a name="line1116"></a>1116
|
1717
|
+
</span><span class="inferred1"><a name="line1117"></a>1117 # Returns a Hash of the URI segments.
|
1718
|
+
</span><span class="marked0"><a name="line1118"></a>1118 def to_hash
|
1719
|
+
</span><span class="inferred1"><a name="line1119"></a>1119 return {
|
1720
|
+
</span><span class="marked0"><a name="line1120"></a>1120 :scheme => self.scheme,
|
1721
|
+
</span><span class="marked1"><a name="line1121"></a>1121 :user => self.user,
|
1722
|
+
</span><span class="marked0"><a name="line1122"></a>1122 :password => self.password,
|
1723
|
+
</span><span class="marked1"><a name="line1123"></a>1123 :host => self.host,
|
1724
|
+
</span><span class="marked0"><a name="line1124"></a>1124 :port => self.specified_port,
|
1725
|
+
</span><span class="marked1"><a name="line1125"></a>1125 :path => self.path,
|
1726
|
+
</span><span class="marked0"><a name="line1126"></a>1126 :query => self.query,
|
1727
|
+
</span><span class="marked1"><a name="line1127"></a>1127 :fragment => self.fragment
|
1728
|
+
</span><span class="marked0"><a name="line1128"></a>1128 }
|
1729
|
+
</span><span class="marked1"><a name="line1129"></a>1129 end
|
1730
|
+
</span><span class="inferred0"><a name="line1130"></a>1130
|
1731
|
+
</span><span class="inferred1"><a name="line1131"></a>1131 # Returns a string representation of the URI object's state.
|
1732
|
+
</span><span class="marked0"><a name="line1132"></a>1132 def inspect
|
1733
|
+
</span><span class="marked1"><a name="line1133"></a>1133 sprintf("#<%s:%#0x URI:%s>", self.class.to_s, self.object_id, self.to_s)
|
1734
|
+
</span><span class="marked0"><a name="line1134"></a>1134 end
|
1735
|
+
</span><span class="inferred1"><a name="line1135"></a>1135
|
1736
|
+
</span><span class="inferred0"><a name="line1136"></a>1136 # This module handles internationalized domain names. When Ruby has an
|
1737
|
+
</span><span class="inferred1"><a name="line1137"></a>1137 # implementation of nameprep, stringprep, punycode, etc, this
|
1738
|
+
</span><span class="inferred0"><a name="line1138"></a>1138 # module should contain an actual implementation of IDNA instead of
|
1739
|
+
</span><span class="inferred1"><a name="line1139"></a>1139 # returning nil if libidn can't be used.
|
1740
|
+
</span><span class="marked0"><a name="line1140"></a>1140 module IDNA
|
1741
|
+
</span><span class="inferred1"><a name="line1141"></a>1141 # Returns the ascii representation of the label.
|
1742
|
+
</span><span class="marked0"><a name="line1142"></a>1142 def self.to_ascii(label)
|
1743
|
+
</span><span class="marked1"><a name="line1143"></a>1143 return nil if label.nil?
|
1744
|
+
</span><span class="marked0"><a name="line1144"></a>1144 if self.use_libidn?
|
1745
|
+
</span><span class="marked1"><a name="line1145"></a>1145 return IDN::Idna.toASCII(label)
|
1746
|
+
</span><span class="inferred0"><a name="line1146"></a>1146 else
|
1747
|
+
</span><span class="marked1"><a name="line1147"></a>1147 raise NotImplementedError,
|
1748
|
+
</span><span class="inferred0"><a name="line1148"></a>1148 "There is no available pure-ruby implementation. " +
|
1749
|
+
</span><span class="inferred1"><a name="line1149"></a>1149 "Install libidn bindings."
|
1750
|
+
</span><span class="inferred0"><a name="line1150"></a>1150 end
|
1751
|
+
</span><span class="inferred1"><a name="line1151"></a>1151 end
|
1752
|
+
</span><span class="inferred0"><a name="line1152"></a>1152
|
1753
|
+
</span><span class="inferred1"><a name="line1153"></a>1153 # Returns the unicode representation of the label.
|
1754
|
+
</span><span class="marked0"><a name="line1154"></a>1154 def self.to_unicode(label)
|
1755
|
+
</span><span class="marked1"><a name="line1155"></a>1155 return nil if label.nil?
|
1756
|
+
</span><span class="marked0"><a name="line1156"></a>1156 if self.use_libidn?
|
1757
|
+
</span><span class="marked1"><a name="line1157"></a>1157 return IDN::Idna.toUnicode(label)
|
1758
|
+
</span><span class="inferred0"><a name="line1158"></a>1158 else
|
1759
|
+
</span><span class="marked1"><a name="line1159"></a>1159 raise NotImplementedError,
|
1760
|
+
</span><span class="inferred0"><a name="line1160"></a>1160 "There is no available pure-ruby implementation. " +
|
1761
|
+
</span><span class="inferred1"><a name="line1161"></a>1161 "Install libidn bindings."
|
1762
|
+
</span><span class="inferred0"><a name="line1162"></a>1162 end
|
1763
|
+
</span><span class="inferred1"><a name="line1163"></a>1163 end
|
1764
|
+
</span><span class="inferred0"><a name="line1164"></a>1164
|
1765
|
+
</span><span class="marked1"><a name="line1165"></a>1165 private
|
1766
|
+
</span><span class="inferred0"><a name="line1166"></a>1166 # Determines if the libidn bindings are available and able to be used.
|
1767
|
+
</span><span class="marked1"><a name="line1167"></a>1167 def self.use_libidn?
|
1768
|
+
</span><span class="marked0"><a name="line1168"></a>1168 if !defined?(@use_libidn) || @use_libidn.nil?
|
1769
|
+
</span><span class="marked1"><a name="line1169"></a>1169 begin
|
1770
|
+
</span><span class="marked0"><a name="line1170"></a>1170 require 'rubygems'
|
1771
|
+
</span><span class="inferred1"><a name="line1171"></a>1171 rescue LoadError
|
1772
|
+
</span><span class="marked0"><a name="line1172"></a>1172 nil
|
1773
|
+
</span><span class="inferred1"><a name="line1173"></a>1173 end
|
1774
|
+
</span><span class="marked0"><a name="line1174"></a>1174 begin
|
1775
|
+
</span><span class="marked1"><a name="line1175"></a>1175 require 'idn'
|
1776
|
+
</span><span class="inferred0"><a name="line1176"></a>1176 rescue LoadError
|
1777
|
+
</span><span class="marked1"><a name="line1177"></a>1177 nil
|
1778
|
+
</span><span class="inferred0"><a name="line1178"></a>1178 end
|
1779
|
+
</span><span class="marked1"><a name="line1179"></a>1179 @use_libidn = !!(defined?(IDN::Idna))
|
1780
|
+
</span><span class="inferred0"><a name="line1180"></a>1180 end
|
1781
|
+
</span><span class="marked1"><a name="line1181"></a>1181 return @use_libidn
|
1782
|
+
</span><span class="inferred0"><a name="line1182"></a>1182 end
|
1783
|
+
</span><span class="inferred1"><a name="line1183"></a>1183 end
|
1784
|
+
</span><span class="inferred0"><a name="line1184"></a>1184
|
1785
|
+
</span><span class="marked1"><a name="line1185"></a>1185 private
|
1786
|
+
</span><span class="inferred0"><a name="line1186"></a>1186 # Resolves paths to their simplest form.
|
1787
|
+
</span><span class="marked1"><a name="line1187"></a>1187 def self.normalize_path(path)
|
1788
|
+
</span><span class="inferred0"><a name="line1188"></a>1188 # Section 5.2.4 of RFC 3986
|
1789
|
+
</span><span class="inferred1"><a name="line1189"></a>1189
|
1790
|
+
</span><span class="marked0"><a name="line1190"></a>1190 return nil if path.nil?
|
1791
|
+
</span><span class="marked1"><a name="line1191"></a>1191 normalized_path = path.dup
|
1792
|
+
</span><span class="marked0"><a name="line1192"></a>1192 previous_state = normalized_path.dup
|
1793
|
+
</span><span class="inferred1"><a name="line1193"></a>1193 begin
|
1794
|
+
</span><span class="marked0"><a name="line1194"></a>1194 previous_state = normalized_path.dup
|
1795
|
+
</span><span class="marked1"><a name="line1195"></a>1195 normalized_path.gsub!(/\/\.\//, "/")
|
1796
|
+
</span><span class="marked0"><a name="line1196"></a>1196 normalized_path.gsub!(/\/\.$/, "/")
|
1797
|
+
</span><span class="marked1"><a name="line1197"></a>1197 parent = normalized_path.scan(/\/([^\/]+)\/\.\.\//).flatten[0]
|
1798
|
+
</span><span class="marked0"><a name="line1198"></a>1198 if parent != "." && parent != ".."
|
1799
|
+
</span><span class="marked1"><a name="line1199"></a>1199 normalized_path.gsub!(/\/#{parent}\/\.\.\//, "/")
|
1800
|
+
</span><span class="inferred0"><a name="line1200"></a>1200 end
|
1801
|
+
</span><span class="marked1"><a name="line1201"></a>1201 parent = normalized_path.scan(/\/([^\/]+)\/\.\.$/).flatten[0]
|
1802
|
+
</span><span class="marked0"><a name="line1202"></a>1202 if parent != "." && parent != ".."
|
1803
|
+
</span><span class="marked1"><a name="line1203"></a>1203 normalized_path.gsub!(/\/#{parent}\/\.\.$/, "/")
|
1804
|
+
</span><span class="inferred0"><a name="line1204"></a>1204 end
|
1805
|
+
</span><span class="marked1"><a name="line1205"></a>1205 normalized_path.gsub!(/^\.\.?\/?/, "")
|
1806
|
+
</span><span class="marked0"><a name="line1206"></a>1206 normalized_path.gsub!(/^\/\.\.?\//, "/")
|
1807
|
+
</span><span class="marked1"><a name="line1207"></a>1207 end until previous_state == normalized_path
|
1808
|
+
</span><span class="marked0"><a name="line1208"></a>1208 return normalized_path
|
1809
|
+
</span><span class="inferred1"><a name="line1209"></a>1209 end
|
1810
|
+
</span><span class="inferred0"><a name="line1210"></a>1210
|
1811
|
+
</span><span class="inferred1"><a name="line1211"></a>1211 # Ensures that the URI is valid.
|
1812
|
+
</span><span class="marked0"><a name="line1212"></a>1212 def validate
|
1813
|
+
</span><span class="marked1"><a name="line1213"></a>1213 if self.scheme != nil &&
|
1814
|
+
</span><span class="marked0"><a name="line1214"></a>1214 (self.host == nil || self.host == "") &&
|
1815
|
+
</span><span class="marked1"><a name="line1215"></a>1215 (self.path == nil || self.path == "")
|
1816
|
+
</span><span class="marked0"><a name="line1216"></a>1216 raise InvalidURIError,
|
1817
|
+
</span><span class="inferred1"><a name="line1217"></a>1217 "Absolute URI missing hierarchical segment."
|
1818
|
+
</span><span class="inferred0"><a name="line1218"></a>1218 end
|
1819
|
+
</span><span class="marked1"><a name="line1219"></a>1219 if self.host == nil
|
1820
|
+
</span><span class="marked0"><a name="line1220"></a>1220 if self.specified_port != nil ||
|
1821
|
+
</span><span class="marked1"><a name="line1221"></a>1221 self.user != nil ||
|
1822
|
+
</span><span class="marked0"><a name="line1222"></a>1222 self.password != nil
|
1823
|
+
</span><span class="marked1"><a name="line1223"></a>1223 raise InvalidURIError, "Hostname not supplied."
|
1824
|
+
</span><span class="inferred0"><a name="line1224"></a>1224 end
|
1825
|
+
</span><span class="inferred1"><a name="line1225"></a>1225 end
|
1826
|
+
</span><span class="inferred0"><a name="line1226"></a>1226 end
|
1827
|
+
</span><span class="inferred1"><a name="line1227"></a>1227
|
1828
|
+
</span><span class="inferred0"><a name="line1228"></a>1228 # Replaces the internal state of self with the specified URI's state.
|
1829
|
+
</span><span class="inferred1"><a name="line1229"></a>1229 # Used in destructive operations to avoid massive code repetition.
|
1830
|
+
</span><span class="marked0"><a name="line1230"></a>1230 def replace_self(uri)
|
1831
|
+
</span><span class="inferred1"><a name="line1231"></a>1231 # Reset dependant values
|
1832
|
+
</span><span class="marked0"><a name="line1232"></a>1232 @userinfo = nil
|
1833
|
+
</span><span class="marked1"><a name="line1233"></a>1233 @authority = nil
|
1834
|
+
</span><span class="inferred0"><a name="line1234"></a>1234
|
1835
|
+
</span><span class="marked1"><a name="line1235"></a>1235 @scheme = uri.scheme
|
1836
|
+
</span><span class="marked0"><a name="line1236"></a>1236 @user = uri.user
|
1837
|
+
</span><span class="marked1"><a name="line1237"></a>1237 @password = uri.password
|
1838
|
+
</span><span class="marked0"><a name="line1238"></a>1238 @host = uri.host
|
1839
|
+
</span><span class="marked1"><a name="line1239"></a>1239 @specified_port = uri.instance_variable_get("@specified_port")
|
1840
|
+
</span><span class="marked0"><a name="line1240"></a>1240 @port = @specified_port.to_s.to_i
|
1841
|
+
</span><span class="marked1"><a name="line1241"></a>1241 @path = uri.path
|
1842
|
+
</span><span class="marked0"><a name="line1242"></a>1242 @query = uri.query
|
1843
|
+
</span><span class="marked1"><a name="line1243"></a>1243 @fragment = uri.fragment
|
1844
|
+
</span><span class="marked0"><a name="line1244"></a>1244 return self
|
1845
|
+
</span><span class="inferred1"><a name="line1245"></a>1245 end
|
1846
|
+
</span><span class="inferred0"><a name="line1246"></a>1246 end
|
1847
|
+
</span><span class="inferred1"><a name="line1247"></a>1247 end
|
1845
1848
|
</span></pre><hr/>
|
1846
1849
|
<p>Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'>rcov code coverage analysis tool for Ruby</a>
|
1847
1850
|
version 0.8.1.2.</p>
|