normalize_url 0.0.3 → 0.0.4
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/README.md +18 -12
- data/lib/normalize_url/normalizer.rb +5 -0
- data/lib/normalize_url/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc28344596c36795dbe9e99a32aafef83338b833
|
4
|
+
data.tar.gz: f6d80c0b99786a59e03bd4a79a9da857ce6cabc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
-
|
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
|
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.
|
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-
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|