normalize_url 0.0.3 → 0.0.4

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: 55028bf73f8d7ab29f8b6eed85f5af3645e2b1a5
4
- data.tar.gz: cc45799207ab2006d5d145441897a621ccc2fc71
3
+ metadata.gz: fc28344596c36795dbe9e99a32aafef83338b833
4
+ data.tar.gz: f6d80c0b99786a59e03bd4a79a9da857ce6cabc8
5
5
  SHA512:
6
- metadata.gz: a394f7e5d7f4de0d0dd5b5331efc30de7872aae59e5c695b14e957bf4cf3f5effbf1d451a39894c63b09813db9e4c75e59f954c17ede921910c90986bfd951f7
7
- data.tar.gz: 16a6d91566ce59953ed3a3ed063ff843320826c45cf5a9a7742172dbf982a02f1756354a5c984fe85ab8b9acc781a968146238441feeaa0e61030cac8809ac8b
6
+ metadata.gz: ea1afeacb3afecd2925ad6f21ff453a4aba887e34e58d900c3ae1444d8b35e0825071f385278ee5530fb5d802eafe763d1413f65b7e1f3bd59df0dca5151088c
7
+ data.tar.gz: 1ee821c5e8a359a8d2cb6065add1d3068fa3b5e6c851cdb5614d4b80bbf9fcc8fb6857220ee3596bdf45de8b581d36d711b552a17f025364ad5efae3ac82e70e
data/README.md CHANGED
@@ -9,16 +9,16 @@ resource should look exactly the same.
9
9
 
10
10
  For example:
11
11
 
12
- - `http://example.com/products`
13
- - `HTTP://EXAMPLE.COM/products/`
14
- - `http://example.com/products/`
15
- - `http://example.com/foo/../products`
16
- - `http://example.com/products#comments-section`
17
- - `http://example.com//products/`
18
- - `http://example.com/products?`
19
- - `http://example.com/products?utm_source=whatever`
12
+ - `http://example.com/products?product_id=123`
13
+ - `HTTP://EXAMPLE.COM/products/?product_id=123`
14
+ - `http://example.com/products/?product_id=123`
15
+ - `http://example.com/foo/../products?product_id=123`
16
+ - `http://example.com/products?product_id=123#comments-section`
17
+ - `http://example.com//products/?product_id=123`
18
+ - `http://example.com//products/?product_id=123&`
19
+ - `http://example.com/products?utm_source=whatever&product_id=123&utm_medium=twitter&utm_campaign=blah`
20
20
 
21
- will all become `http://example.com/products` after normalization.
21
+ will all become `http://example.com/products?product_id=123` after normalization.
22
22
 
23
23
  Some of the transformations are potentially dangerous, since not all webservers
24
24
  comform to standards and some of them are just plain weird. So there is no
@@ -55,13 +55,13 @@ NormalizeUrl.process("http://example.com/foo/", remove_trailing_slash: false) #
55
55
 
56
56
  ## Transformations
57
57
 
58
- - Remove trailing slash. Option `:remove_trailing_slash`
58
+ - Remove trailing slash. Option `:remove_trailing_slash`.
59
59
 
60
60
  Example:
61
61
 
62
62
  `http://example.com/products/` -> `http://example.com/products`
63
63
 
64
- - Remove repeating slashes. Option `:remove_repeating_slashes`
64
+ - Remove repeating slashes. Option `:remove_repeating_slashes`.
65
65
 
66
66
  Example:
67
67
 
@@ -73,7 +73,13 @@ NormalizeUrl.process("http://example.com/foo/", remove_trailing_slash: false) #
73
73
 
74
74
  `http://example.com/foo#bar` -> `http://example.com/foo`
75
75
 
76
- - Remove tracking. Option `:remove_tracking`.
76
+ - Reparse query params. Option `:reparse_query`.
77
+
78
+ Example:
79
+
80
+ `http://example.com/?foo=BAR+BAZ` -> `http://example.com/?foo=BAR%20BAZ`
81
+
82
+ - Remove known commonly used tracking query parameters. Option `:remove_tracking`.
77
83
 
78
84
  Example:
79
85
 
@@ -30,6 +30,7 @@ module NormalizeUrl
30
30
  process :remove_trailing_slash
31
31
  process :remove_repeating_slashes
32
32
  process :remove_hash
33
+ process :reparse_query
33
34
  process :remove_tracking
34
35
  process :remove_params
35
36
  process :sort_query
@@ -70,6 +71,10 @@ module NormalizeUrl
70
71
  remove_params Array(@options.fetch(:remove_params, nil)).map(&:to_s)
71
72
  end
72
73
 
74
+ def process_reparse_query
75
+ uri.query_values = uri.query_values.to_a
76
+ end
77
+
73
78
  def remove_params(params)
74
79
  return unless uri.query_values
75
80
  original = uri.query_values
@@ -1,3 +1,3 @@
1
1
  module NormalizeUrl
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: normalize_url
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pravosud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-18 00:00:00.000000000 Z
11
+ date: 2014-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable