fuzzyurl 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c776f197c4a67210a4f28d6aae36964f4df56104
4
- data.tar.gz: 818e98e321eb54afe95b643e368472ff7ab719ad
3
+ metadata.gz: 7e03c07bf920781777e67d73cee148dc4d98a9d9
4
+ data.tar.gz: 2bf399db13171703e3a03ef65128e5c48aba16aa
5
5
  SHA512:
6
- metadata.gz: a3c90e49a699fcea3f7e9b117a52b36d5728b29179a03d6a337038101b8a2c97c6dee5d2601589c879519827df931e77fbb4aecf77bfd616e7dd08f7dcd2a50b
7
- data.tar.gz: d1e34f6f08c77d3a22fc2dfbf1a3c07ab2807f98f9fcf5fbfff84a0c90fbaf1875a1e76718617b68dbce7a57e7dfc015216f1cf7a477ba529daf7e4df8fb1092
6
+ metadata.gz: 34d8da13ae4c79c2e2b912e085ddd3675b8b6b73dec2546f505368790b98c95b057597f636c05adab11b2228c2fdd847c7f0f0d68fba49677f06b441e6b4fa0d
7
+ data.tar.gz: e62e3737a82ccc2f95337b4ee06079d5e619a3e124c96f98ed052c32bd5857f6108b6922201c2d221eeb5f5bdab189ed27b54dea2e4a78cc5b2d5687db6794de
@@ -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
- if mask_hash[:port] && mask_port != '*'
53
- if mask_port == PORT_BY_PROTOCOL[url_protocol]
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
@@ -1,6 +1,6 @@
1
1
  # @private
2
2
  class FuzzyURL
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  VERSION_DATE = '2014-04-03'
5
5
  end
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuzzyurl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Gamache