fuzzyurl 0.2.0 → 0.2.1
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/lib/fuzzy_url/matching.rb +12 -10
- data/lib/fuzzy_url/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e03c07bf920781777e67d73cee148dc4d98a9d9
|
4
|
+
data.tar.gz: 2bf399db13171703e3a03ef65128e5c48aba16aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34d8da13ae4c79c2e2b912e085ddd3675b8b6b73dec2546f505368790b98c95b057597f636c05adab11b2228c2fdd847c7f0f0d68fba49677f06b441e6b4fa0d
|
7
|
+
data.tar.gz: e62e3737a82ccc2f95337b4ee06079d5e619a3e124c96f98ed052c32bd5857f6108b6922201c2d221eeb5f5bdab189ed27b54dea2e4a78cc5b2d5687db6794de
|
data/lib/fuzzy_url/matching.rb
CHANGED
@@ -19,7 +19,6 @@ class FuzzyURL
|
|
19
19
|
tally.call match_hostnames(mask[:hostname], url[:hostname])
|
20
20
|
tally.call match_protocols_and_ports(mask, url)
|
21
21
|
tally.call match_paths(mask[:path], url[:path])
|
22
|
-
tally.call fuzzy_match(mask[:port], url[:port])
|
23
22
|
tally.call fuzzy_match(mask[:query], url[:query])
|
24
23
|
tally.call fuzzy_match(mask[:username], url[:username])
|
25
24
|
tally.call fuzzy_match(mask[:password], url[:password])
|
@@ -48,15 +47,17 @@ class FuzzyURL
|
|
48
47
|
end
|
49
48
|
|
50
49
|
mask_port = mask_hash[:port]
|
51
|
-
url_port = url_hash[:port]
|
52
|
-
|
53
|
-
|
54
|
-
wildcard_matches += 1
|
55
|
-
else
|
56
|
-
return nil if mask_port != url_port
|
57
|
-
end
|
58
|
-
else
|
50
|
+
url_port = url_hash[:port] # || PORT_BY_PROTOCOL[url_protocol]
|
51
|
+
|
52
|
+
if !mask_port || mask_port == '*'
|
59
53
|
wildcard_matches += 1
|
54
|
+
elsif !url_port && PORT_BY_PROTOCOL[url_protocol] == mask_port.to_i
|
55
|
+
wildcard_matches += 1
|
56
|
+
elsif mask_port == url_port
|
57
|
+
## cool
|
58
|
+
else
|
59
|
+
## not cool
|
60
|
+
return nil
|
60
61
|
end
|
61
62
|
|
62
63
|
(2 - wildcard_matches)
|
@@ -65,7 +66,6 @@ class FuzzyURL
|
|
65
66
|
PORT_BY_PROTOCOL = {
|
66
67
|
'http' => 80,
|
67
68
|
'https' => 443,
|
68
|
-
'file' => nil,
|
69
69
|
}
|
70
70
|
|
71
71
|
## Matches a picee of a mask against a piece of a URL. Handles wildcards.
|
@@ -92,6 +92,8 @@ class FuzzyURL
|
|
92
92
|
## Returns nil for no match, 0 for a wildcard match, or 1 for an
|
93
93
|
## exact match.
|
94
94
|
def match_paths(mask, path)
|
95
|
+
mask = '/'+mask if mask && mask.index('/') != 0
|
96
|
+
path = '/'+path if path && path.index('/') != 0
|
95
97
|
mask_pieces = (mask || '*').split(%r{/})
|
96
98
|
path_pieces = (path || '/').split(%r{/})
|
97
99
|
return 1 if mask && path && mask_pieces==path_pieces
|
data/lib/fuzzy_url/version.rb
CHANGED