url_compare 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/url_compare.rb +15 -4
  2. metadata +1 -1
data/lib/url_compare.rb CHANGED
@@ -1,11 +1,22 @@
1
1
  class UrlCompare
2
- def self.similar?(first_url, second_url)
3
- strip_url(first_url) == strip_url(second_url)
2
+ def self.similar?(first_url, second_url, options = {})
3
+ if options[:strict]
4
+ first_url == second_url
5
+ else
6
+ strip_url(first_url, options) == strip_url(second_url, options)
7
+ end
8
+ end
9
+
10
+ def self.normalize(url, options = {})
11
+ strip_url(url, options)
4
12
  end
5
13
 
6
14
  private
7
15
 
8
- def self.strip_url(url)
9
- url.split('#')[0].sub('//www.', '//').chomp('/')
16
+ def self.strip_url(url, options)
17
+ result = url
18
+
19
+ result = result.split('?')[0] if options[:ignore_params]
20
+ result.split('#')[0].sub('//www.', '//').chomp('/')
10
21
  end
11
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: url_compare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: