furi 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Gemfile +0 -1
- data/lib/furi/uri.rb +26 -2
- data/lib/furi/version.rb +1 -1
- data/lib/furi.rb +5 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5923ee7cbb73b1b035612324a274790d95ec2cef4369558fc6874e28da4fe77b
|
|
4
|
+
data.tar.gz: bebdc6c2ab8ae6b5a8cc262c2c70d53a8d1721020fcd7581a713f9f2f629b010
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9b9a3c1d0116faa7828205294fc22b6eb2045536ffdd3c3665d7d8ea8dc4de3ac88bd43904f82c9c33948e943c073e9c0a44dc5a6c6a80e4b30252fd690b49f4
|
|
7
|
+
data.tar.gz: 5ef899e9301205592801d7f037d7193d4f1f13c057198fa3eff06e559e86bcdb8b209df0e77e24aad04f8d555ff4aaf443e8373adc3f79dc17360c24e330787a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# v0.2.7
|
|
2
|
+
|
|
3
|
+
* Add `origin` part (location + path, without query string and anchor)
|
|
4
|
+
|
|
5
|
+
```ruby
|
|
6
|
+
Furi.parse("http://gusiev.com/articles/index.html?a=1#top").origin
|
|
7
|
+
# => "http://gusiev.com/articles/index.html"
|
|
8
|
+
|
|
9
|
+
Furi.replace("http://gusiev.com/index.html?a=1#top", origin: "http://gusiev.com/blog.html")
|
|
10
|
+
# => "http://gusiev.com/blog.html?a=1#top"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
# v0.2.6
|
|
14
|
+
|
|
15
|
+
* Support `filename` part replacement and extraction
|
|
16
|
+
|
|
17
|
+
# v0.2.5
|
|
18
|
+
|
|
19
|
+
* Fix replacement of path starting with `/`
|
|
20
|
+
|
|
1
21
|
# v0.2.4
|
|
2
22
|
|
|
3
23
|
* Improved `Furi.update` behavior for `path:` overrides:
|
data/Gemfile
CHANGED
data/lib/furi/uri.rb
CHANGED
|
@@ -207,6 +207,18 @@ module Furi
|
|
|
207
207
|
end
|
|
208
208
|
end
|
|
209
209
|
|
|
210
|
+
def origin
|
|
211
|
+
[location, path].join
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def origin=(string)
|
|
215
|
+
string ||= ""
|
|
216
|
+
string = parse_protocol(string)
|
|
217
|
+
authority, path = string.split("/", 2)
|
|
218
|
+
self.authority = authority
|
|
219
|
+
self.path = path ? "/#{path}" : nil
|
|
220
|
+
end
|
|
221
|
+
|
|
210
222
|
def location=(string)
|
|
211
223
|
string ||= ""
|
|
212
224
|
string = string.gsub(%r(/\Z), '')
|
|
@@ -327,9 +339,21 @@ module Furi
|
|
|
327
339
|
self.path = string + file.to_s
|
|
328
340
|
end
|
|
329
341
|
|
|
342
|
+
def filename
|
|
343
|
+
return nil unless file
|
|
344
|
+
file_tokens.first
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
def filename=(value)
|
|
348
|
+
t = file_tokens
|
|
349
|
+
t[0] = value
|
|
350
|
+
self.file = t.join(".")
|
|
351
|
+
end
|
|
352
|
+
|
|
330
353
|
def extension
|
|
331
354
|
return nil unless file
|
|
332
|
-
|
|
355
|
+
tokens = file_tokens[1..-1]
|
|
356
|
+
tokens.any? ? tokens.join(".") : nil
|
|
333
357
|
end
|
|
334
358
|
|
|
335
359
|
def extension=(string)
|
|
@@ -341,7 +365,7 @@ module Furi
|
|
|
341
365
|
tokens.push(string)
|
|
342
366
|
else
|
|
343
367
|
if string
|
|
344
|
-
tokens
|
|
368
|
+
tokens = [tokens.first, string]
|
|
345
369
|
else
|
|
346
370
|
tokens.pop
|
|
347
371
|
end
|
data/lib/furi/version.rb
CHANGED
data/lib/furi.rb
CHANGED
|
@@ -9,13 +9,16 @@ module Furi
|
|
|
9
9
|
|
|
10
10
|
ESSENTIAL_PARTS = [
|
|
11
11
|
:anchor, :protocol, :query_tokens,
|
|
12
|
-
:path, :host, :port, :username, :password
|
|
12
|
+
:path, :host, :port, :username, :password,
|
|
13
|
+
:filename,
|
|
13
14
|
]
|
|
15
|
+
|
|
14
16
|
COMBINED_PARTS = [
|
|
15
17
|
:hostinfo, :userinfo, :authority, :ssl, :domain, :domainname,
|
|
16
|
-
:domainzone, :request, :location, :query,
|
|
18
|
+
:domainzone, :request, :location, :origin, :query,
|
|
17
19
|
:directory, :extension, :file
|
|
18
20
|
]
|
|
21
|
+
|
|
19
22
|
PARTS = ESSENTIAL_PARTS + COMBINED_PARTS
|
|
20
23
|
|
|
21
24
|
ALIASES = {
|