url_canonicalize 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 +4 -4
- data/.gitignore +0 -1
- data/.rubocop.yml +11 -10
- data/.ruby-gemset +0 -0
- data/.travis.yml +3 -4
- data/CHANGELOG.md +38 -2
- data/Gemfile +7 -4
- data/Gemfile.lock +102 -0
- data/README.md +0 -1
- data/circle.yml +29 -16
- data/lib/url_canonicalize/http.rb +13 -5
- data/lib/url_canonicalize/request.rb +4 -1
- data/lib/url_canonicalize/uri.rb +3 -1
- data/lib/url_canonicalize/version.rb +1 -1
- data/url_canonicalize.gemspec +9 -7
- metadata +12 -12
- data/Gemfile.local.example +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cc361f6fdfb5137149371de473d9188bb56a69b93b1cc1f234a1dc9d9cefd79
|
4
|
+
data.tar.gz: d3074abf07ec9ff566a71b15d261fa2333ad19448788276a81f406942649da68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df734b09b21540b1146a105545f6d840c29dca4cb699f290785329b752ea31bee55c014f8defcef725c93254c20586921f1822581242695a278361c90540aa91
|
7
|
+
data.tar.gz: 4f07815fa2f1c140cc272999229e5f1b3c03c2639d0a9050d6f47bb1cfb6821ac73f5bf38bf14b2b497b2e9c8a227126c9e9fb68e9d642e672f4ce04fea5f158
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -2,11 +2,8 @@
|
|
2
2
|
AllCops:
|
3
3
|
DisplayStyleGuide: true
|
4
4
|
DisplayCopNames: true
|
5
|
-
TargetRubyVersion: 2.
|
6
|
-
|
7
|
-
- '*.gemspec'
|
8
|
-
- spec/**/*
|
9
|
-
|
5
|
+
TargetRubyVersion: 2.6
|
6
|
+
NewCops: enable
|
10
7
|
|
11
8
|
Layout/DotPosition:
|
12
9
|
Description: 'Checks the position of the dot in multi-line method calls.'
|
@@ -17,10 +14,19 @@ Layout/ExtraSpacing:
|
|
17
14
|
Description: 'Do not use unnecessary spacing.'
|
18
15
|
Enabled: true
|
19
16
|
|
17
|
+
Layout/LineLength:
|
18
|
+
Max: 120
|
19
|
+
Exclude:
|
20
|
+
- spec/**/*
|
21
|
+
|
20
22
|
Lint/LiteralInInterpolation:
|
21
23
|
Description: 'Avoid interpolating literals in strings'
|
22
24
|
AutoCorrect: true
|
23
25
|
|
26
|
+
Metrics/BlockLength:
|
27
|
+
Exclude:
|
28
|
+
- spec/**/*
|
29
|
+
|
24
30
|
Metrics/ClassLength:
|
25
31
|
CountComments: false # count full line comments?
|
26
32
|
Max: 200
|
@@ -28,11 +34,6 @@ Metrics/ClassLength:
|
|
28
34
|
Metrics/MethodLength:
|
29
35
|
Max: 12
|
30
36
|
|
31
|
-
Metrics/LineLength:
|
32
|
-
Max: 120
|
33
|
-
Exclude:
|
34
|
-
- spec/**/*
|
35
|
-
|
36
37
|
Naming/FileName:
|
37
38
|
Description: 'Use snake_case for source file names.'
|
38
39
|
Enabled: true
|
data/.ruby-gemset
CHANGED
File without changes
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,21 +1,39 @@
|
|
1
|
-
#
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [Unreleased](https://github.com/dominicsayers/url_canonicalize/tree/HEAD)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.15...HEAD)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- Feature: return a Nokogiri XML document if requested [\#5](https://github.com/dominicsayers/url_canonicalize/issues/5)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Version 0.2 [\#6](https://github.com/dominicsayers/url_canonicalize/pull/6) ([dominicsayers](https://github.com/dominicsayers))
|
2
14
|
|
3
15
|
## [v0.1.15](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.15) (2017-03-14)
|
16
|
+
|
4
17
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.14...v0.1.15)
|
5
18
|
|
6
19
|
## [v0.1.14](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.14) (2017-03-13)
|
20
|
+
|
7
21
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.13...v0.1.14)
|
8
22
|
|
9
23
|
## [v0.1.13](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.13) (2017-03-13)
|
24
|
+
|
10
25
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.12...v0.1.13)
|
11
26
|
|
12
27
|
## [v0.1.12](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.12) (2017-03-13)
|
28
|
+
|
13
29
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.11...v0.1.12)
|
14
30
|
|
15
31
|
## [v0.1.11](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.11) (2017-03-13)
|
32
|
+
|
16
33
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.10...v0.1.11)
|
17
34
|
|
18
35
|
## [v0.1.10](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.10) (2017-03-13)
|
36
|
+
|
19
37
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.9...v0.1.10)
|
20
38
|
|
21
39
|
**Closed issues:**
|
@@ -23,9 +41,11 @@
|
|
23
41
|
- URLCanonicalize doesn't accept host names [\#4](https://github.com/dominicsayers/url_canonicalize/issues/4)
|
24
42
|
|
25
43
|
## [v0.1.9](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.9) (2017-03-06)
|
44
|
+
|
26
45
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.8...v0.1.9)
|
27
46
|
|
28
47
|
## [v0.1.8](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.8) (2017-03-06)
|
48
|
+
|
29
49
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.7...v0.1.8)
|
30
50
|
|
31
51
|
**Closed issues:**
|
@@ -33,6 +53,7 @@
|
|
33
53
|
- Use a later version of Ruby on CircleCI [\#3](https://github.com/dominicsayers/url_canonicalize/issues/3)
|
34
54
|
|
35
55
|
## [v0.1.7](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.7) (2017-03-06)
|
56
|
+
|
36
57
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.6...v0.1.7)
|
37
58
|
|
38
59
|
**Closed issues:**
|
@@ -40,42 +61,57 @@
|
|
40
61
|
- Insecure version of Nokogiri [\#2](https://github.com/dominicsayers/url_canonicalize/issues/2)
|
41
62
|
|
42
63
|
## [v0.1.6](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.6) (2017-03-06)
|
64
|
+
|
43
65
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.5...v0.1.6)
|
44
66
|
|
45
67
|
## [v0.1.5](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.5) (2016-10-26)
|
68
|
+
|
46
69
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.4...v0.1.5)
|
47
70
|
|
48
71
|
## [v0.1.4](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.4) (2016-10-26)
|
72
|
+
|
49
73
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.2...v0.1.4)
|
50
74
|
|
51
75
|
## [v0.1.2](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.2) (2016-10-26)
|
76
|
+
|
52
77
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.1...v0.1.2)
|
53
78
|
|
54
79
|
## [v0.1.1](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.1) (2016-10-26)
|
80
|
+
|
55
81
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.1.0...v0.1.1)
|
56
82
|
|
57
83
|
## [v0.1.0](https://github.com/dominicsayers/url_canonicalize/tree/v0.1.0) (2016-10-20)
|
84
|
+
|
58
85
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.0.7...v0.1.0)
|
59
86
|
|
60
87
|
## [v0.0.7](https://github.com/dominicsayers/url_canonicalize/tree/v0.0.7) (2016-10-20)
|
88
|
+
|
61
89
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.0.6...v0.0.7)
|
62
90
|
|
63
91
|
## [v0.0.6](https://github.com/dominicsayers/url_canonicalize/tree/v0.0.6) (2016-10-20)
|
92
|
+
|
64
93
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.0.5...v0.0.6)
|
65
94
|
|
66
95
|
## [v0.0.5](https://github.com/dominicsayers/url_canonicalize/tree/v0.0.5) (2016-10-20)
|
96
|
+
|
67
97
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.0.4...v0.0.5)
|
68
98
|
|
69
99
|
## [v0.0.4](https://github.com/dominicsayers/url_canonicalize/tree/v0.0.4) (2016-10-20)
|
100
|
+
|
70
101
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.0.3...v0.0.4)
|
71
102
|
|
72
103
|
## [v0.0.3](https://github.com/dominicsayers/url_canonicalize/tree/v0.0.3) (2016-10-20)
|
104
|
+
|
73
105
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.0.2...v0.0.3)
|
74
106
|
|
75
107
|
## [v0.0.2](https://github.com/dominicsayers/url_canonicalize/tree/v0.0.2) (2016-10-20)
|
108
|
+
|
76
109
|
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/v0.0.1...v0.0.2)
|
77
110
|
|
78
111
|
## [v0.0.1](https://github.com/dominicsayers/url_canonicalize/tree/v0.0.1) (2016-10-20)
|
79
112
|
|
113
|
+
[Full Changelog](https://github.com/dominicsayers/url_canonicalize/compare/fec855bec42813304f93c8ef87035f184b054344...v0.0.1)
|
114
|
+
|
115
|
+
|
80
116
|
|
81
|
-
\* *This
|
117
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile
CHANGED
@@ -4,6 +4,11 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
+
group :static_code_analysis do
|
8
|
+
gem 'rubocop', require: false
|
9
|
+
gem 'rubocop-rspec', require: false
|
10
|
+
end
|
11
|
+
|
7
12
|
group :test do
|
8
13
|
gem 'coveralls', require: false
|
9
14
|
gem 'rspec'
|
@@ -12,8 +17,6 @@ group :test do
|
|
12
17
|
gem 'webmock'
|
13
18
|
end
|
14
19
|
|
15
|
-
|
16
|
-
|
17
|
-
if File.exist?(local_gemfile)
|
18
|
-
eval(File.read(local_gemfile)) # rubocop:disable Security/Eval
|
20
|
+
group :build do
|
21
|
+
gem 'gem-release', require: false
|
19
22
|
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
url_canonicalize (0.2.1)
|
5
|
+
addressable (~> 2)
|
6
|
+
nokogiri (>= 1.13)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.8.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
ast (2.4.2)
|
14
|
+
coveralls (0.7.2)
|
15
|
+
multi_json (~> 1.3)
|
16
|
+
rest-client (= 1.6.7)
|
17
|
+
simplecov (>= 0.7)
|
18
|
+
term-ansicolor (= 1.2.2)
|
19
|
+
thor (= 0.18.1)
|
20
|
+
crack (0.4.5)
|
21
|
+
rexml
|
22
|
+
diff-lcs (1.5.0)
|
23
|
+
docile (1.4.0)
|
24
|
+
gem-release (2.2.2)
|
25
|
+
hashdiff (1.0.1)
|
26
|
+
mime-types (3.4.1)
|
27
|
+
mime-types-data (~> 3.2015)
|
28
|
+
mime-types-data (3.2022.0105)
|
29
|
+
multi_json (1.15.0)
|
30
|
+
nokogiri (1.13.1-x86_64-linux)
|
31
|
+
racc (~> 1.4)
|
32
|
+
parallel (1.21.0)
|
33
|
+
parser (3.1.0.0)
|
34
|
+
ast (~> 2.4.1)
|
35
|
+
public_suffix (4.0.6)
|
36
|
+
racc (1.6.0)
|
37
|
+
rainbow (3.1.1)
|
38
|
+
regexp_parser (2.2.0)
|
39
|
+
rest-client (1.6.7)
|
40
|
+
mime-types (>= 1.16)
|
41
|
+
rexml (3.2.5)
|
42
|
+
rspec (3.10.0)
|
43
|
+
rspec-core (~> 3.10.0)
|
44
|
+
rspec-expectations (~> 3.10.0)
|
45
|
+
rspec-mocks (~> 3.10.0)
|
46
|
+
rspec-core (3.10.2)
|
47
|
+
rspec-support (~> 3.10.0)
|
48
|
+
rspec-expectations (3.10.2)
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
+
rspec-support (~> 3.10.0)
|
51
|
+
rspec-mocks (3.10.3)
|
52
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
+
rspec-support (~> 3.10.0)
|
54
|
+
rspec-support (3.10.3)
|
55
|
+
rspec_junit_formatter (0.5.1)
|
56
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
57
|
+
rubocop (1.25.0)
|
58
|
+
parallel (~> 1.10)
|
59
|
+
parser (>= 3.1.0.0)
|
60
|
+
rainbow (>= 2.2.2, < 4.0)
|
61
|
+
regexp_parser (>= 1.8, < 3.0)
|
62
|
+
rexml
|
63
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
64
|
+
ruby-progressbar (~> 1.7)
|
65
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
66
|
+
rubocop-ast (1.15.1)
|
67
|
+
parser (>= 3.0.1.1)
|
68
|
+
rubocop-rspec (2.8.0)
|
69
|
+
rubocop (~> 1.19)
|
70
|
+
ruby-progressbar (1.11.0)
|
71
|
+
simplecov (0.21.2)
|
72
|
+
docile (~> 1.1)
|
73
|
+
simplecov-html (~> 0.11)
|
74
|
+
simplecov_json_formatter (~> 0.1)
|
75
|
+
simplecov-html (0.12.3)
|
76
|
+
simplecov_json_formatter (0.1.3)
|
77
|
+
term-ansicolor (1.2.2)
|
78
|
+
tins (~> 0.8)
|
79
|
+
thor (0.18.1)
|
80
|
+
tins (0.13.2)
|
81
|
+
unicode-display_width (2.1.0)
|
82
|
+
webmock (3.14.0)
|
83
|
+
addressable (>= 2.8.0)
|
84
|
+
crack (>= 0.3.2)
|
85
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
86
|
+
|
87
|
+
PLATFORMS
|
88
|
+
x86_64-linux
|
89
|
+
|
90
|
+
DEPENDENCIES
|
91
|
+
coveralls
|
92
|
+
gem-release
|
93
|
+
rspec
|
94
|
+
rspec_junit_formatter
|
95
|
+
rubocop
|
96
|
+
rubocop-rspec
|
97
|
+
simplecov (~> 0.13)
|
98
|
+
url_canonicalize!
|
99
|
+
webmock
|
100
|
+
|
101
|
+
BUNDLED WITH
|
102
|
+
2.3.6
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
[![Gem downloads](https://img.shields.io/gem/dt/url_canonicalize.svg)](https://rubygems.org/gems/url_canonicalize)
|
4
4
|
[![Build status](https://img.shields.io/circleci/project/dominicsayers/url_canonicalize/master.svg)](https://circleci.com/gh/dominicsayers/url_canonicalize)
|
5
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/1f92f784d12741a942ec/maintainability)](https://codeclimate.com/github/dominicsayers/url_canonicalize/maintainability)
|
6
|
-
[![Test Coverage](https://api.codeclimate.com/v1/badges/1f92f784d12741a942ec/test_coverage)](https://codeclimate.com/github/dominicsayers/url_canonicalize/test_coverage)
|
7
6
|
[![Coverage Status](https://coveralls.io/repos/github/dominicsayers/url_canonicalize/badge.svg?branch=master)](https://coveralls.io/github/dominicsayers/url_canonicalize?branch=master)
|
8
7
|
[![Dependency Status](https://dependencyci.com/github/dominicsayers/url_canonicalize/badge)](https://dependencyci.com/github/dominicsayers/url_canonicalize)
|
9
8
|
[![Security](https://hakiri.io/github/dominicsayers/url_canonicalize/master.svg)](https://hakiri.io/github/dominicsayers/url_canonicalize/master)
|
data/circle.yml
CHANGED
@@ -1,16 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@1.1
|
4
|
+
jobs:
|
5
|
+
check_and_test:
|
6
|
+
parameters:
|
7
|
+
ruby-version:
|
8
|
+
type: string
|
9
|
+
docker:
|
10
|
+
- image: cimg/ruby:<< parameters.ruby-version >>
|
11
|
+
parallelism: 3
|
12
|
+
steps:
|
13
|
+
- checkout
|
14
|
+
- ruby/install-deps
|
15
|
+
- run:
|
16
|
+
name: Run static code analysis
|
17
|
+
command: bundle exec rubocop
|
18
|
+
- run:
|
19
|
+
name: Run tests
|
20
|
+
command: bundle exec rspec
|
21
|
+
workflows:
|
22
|
+
version: 2
|
23
|
+
test:
|
24
|
+
jobs:
|
25
|
+
- check_and_test:
|
26
|
+
# cribbed from http://mikebian.co/running-tests-against-multiple-ruby-versions-using-circleci/
|
27
|
+
matrix:
|
28
|
+
parameters:
|
29
|
+
ruby-version: ["2.6", "2.7", "3.0", "3.1"]
|
@@ -72,6 +72,7 @@ module URLCanonicalize
|
|
72
72
|
def redirect_loop_detected?
|
73
73
|
if redirect_list.include?(response_url)
|
74
74
|
return true if last_known_good
|
75
|
+
|
75
76
|
raise URLCanonicalize::Exception::Redirect, 'Redirect loop detected'
|
76
77
|
end
|
77
78
|
|
@@ -84,6 +85,7 @@ module URLCanonicalize
|
|
84
85
|
def max_redirects_reached?
|
85
86
|
return false unless @redirects > options[:max_redirects]
|
86
87
|
return true if last_known_good
|
88
|
+
|
87
89
|
raise URLCanonicalize::Exception::Redirect, "#{@redirects} redirects is too many"
|
88
90
|
end
|
89
91
|
|
@@ -102,6 +104,7 @@ module URLCanonicalize
|
|
102
104
|
def handle_canonical_found
|
103
105
|
self.last_known_good = response.response
|
104
106
|
return true if response_url == url || redirect_list.include?(response_url)
|
107
|
+
|
105
108
|
set_url_from_response
|
106
109
|
false
|
107
110
|
end
|
@@ -112,6 +115,7 @@ module URLCanonicalize
|
|
112
115
|
|
113
116
|
def handle_failure
|
114
117
|
return true if last_known_good
|
118
|
+
|
115
119
|
raise URLCanonicalize::Exception::Failure, "#{response.failure_class}: #{response.message}"
|
116
120
|
end
|
117
121
|
|
@@ -149,14 +153,18 @@ module URLCanonicalize
|
|
149
153
|
h.open_timeout = options[:open_timeout]
|
150
154
|
h.read_timeout = options[:read_timeout]
|
151
155
|
|
156
|
+
ssl!(h)
|
157
|
+
|
158
|
+
h
|
159
|
+
end
|
160
|
+
|
161
|
+
def ssl!(http)
|
152
162
|
if uri.scheme == 'https'
|
153
|
-
|
154
|
-
|
163
|
+
http.use_ssl = true # Can generate exception
|
164
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
155
165
|
else
|
156
|
-
|
166
|
+
http.use_ssl = false
|
157
167
|
end
|
158
|
-
|
159
|
-
h
|
160
168
|
end
|
161
169
|
|
162
170
|
def options
|
@@ -38,7 +38,7 @@ module URLCanonicalize
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# We can stub this method in testing then call #response any number of times
|
41
|
-
def do_http_request
|
41
|
+
def do_http_request # :nodoc: internal use only
|
42
42
|
http.do_request request # Some URLs can throw an exception here
|
43
43
|
end
|
44
44
|
|
@@ -170,6 +170,7 @@ module URLCanonicalize
|
|
170
170
|
|
171
171
|
def relative_to_absolute(partial_url)
|
172
172
|
return unless partial_url
|
173
|
+
|
173
174
|
partial_uri = ::URI.parse(partial_url)
|
174
175
|
|
175
176
|
if partial_uri.host
|
@@ -183,9 +184,11 @@ module URLCanonicalize
|
|
183
184
|
|
184
185
|
def log_response
|
185
186
|
return unless ENV['DEBUG']
|
187
|
+
|
186
188
|
puts "#{http_method.upcase} #{url} #{response.code} #{response.message}"
|
187
189
|
|
188
190
|
return unless ENV['DEBUG'].casecmp('headers')
|
191
|
+
|
189
192
|
response.each { |k, v| puts " #{k}:\t#{v}" }
|
190
193
|
end
|
191
194
|
|
data/lib/url_canonicalize/uri.rb
CHANGED
@@ -18,16 +18,18 @@ module URLCanonicalize
|
|
18
18
|
def valid?(uri)
|
19
19
|
raise URLCanonicalize::Exception::URI, "#{uri} must be http or https" unless VALID_CLASSES.include?(uri.class)
|
20
20
|
raise URLCanonicalize::Exception::URI, "Missing host name in #{uri}" unless uri.host
|
21
|
+
|
21
22
|
true
|
22
23
|
end
|
23
24
|
|
24
25
|
def decorate(url)
|
25
26
|
return url if url.include? COLON
|
27
|
+
|
26
28
|
"http://#{url}" # Add protocol if we just receive a host name
|
27
29
|
end
|
28
30
|
|
29
31
|
VALID_CLASSES = [::URI::HTTP, ::URI::HTTPS].freeze
|
30
|
-
COLON = ':'
|
32
|
+
COLON = ':'
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
data/url_canonicalize.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'url_canonicalize/version'
|
5
6
|
|
@@ -15,14 +16,15 @@ Gem::Specification.new do |s|
|
|
15
16
|
s.homepage = 'https://github.com/dominicsayers/url_canonicalize'
|
16
17
|
s.license = 'MIT'
|
17
18
|
|
18
|
-
s.
|
19
|
-
|
20
|
-
|
19
|
+
s.required_ruby_version = '>= 2.6.0'
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split($RS).grep_v(%r{^spec/})
|
21
22
|
|
22
23
|
s.test_files = []
|
23
24
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
25
|
s.require_paths = ['lib']
|
25
26
|
|
26
|
-
s.
|
27
|
-
s.
|
27
|
+
s.add_runtime_dependency 'addressable', '~> 2' # To normalize URLs
|
28
|
+
s.add_runtime_dependency 'nokogiri', '>= 1.13' # To look for <link rel="canonical" ...> in HTML
|
29
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
28
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: url_canonicalize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominic Sayers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: '1.13'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: '1.13'
|
41
41
|
description: 'Rubygem that finds the canonical version of a URL by providing #canonicalize
|
42
42
|
methods for the String, URI::HTTP, URI::HTTPS and Addressable::URI classes'
|
43
43
|
email:
|
@@ -55,7 +55,7 @@ files:
|
|
55
55
|
- ".travis.yml"
|
56
56
|
- CHANGELOG.md
|
57
57
|
- Gemfile
|
58
|
-
- Gemfile.
|
58
|
+
- Gemfile.lock
|
59
59
|
- Guardfile
|
60
60
|
- LICENSE
|
61
61
|
- README.md
|
@@ -75,8 +75,9 @@ files:
|
|
75
75
|
homepage: https://github.com/dominicsayers/url_canonicalize
|
76
76
|
licenses:
|
77
77
|
- MIT
|
78
|
-
metadata:
|
79
|
-
|
78
|
+
metadata:
|
79
|
+
rubygems_mfa_required: 'true'
|
80
|
+
post_install_message:
|
80
81
|
rdoc_options: []
|
81
82
|
require_paths:
|
82
83
|
- lib
|
@@ -84,16 +85,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
85
|
requirements:
|
85
86
|
- - ">="
|
86
87
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
88
|
+
version: 2.6.0
|
88
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
90
|
requirements:
|
90
91
|
- - ">="
|
91
92
|
- !ruby/object:Gem::Version
|
92
93
|
version: '0'
|
93
94
|
requirements: []
|
94
|
-
|
95
|
-
|
96
|
-
signing_key:
|
95
|
+
rubygems_version: 3.3.6
|
96
|
+
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Finds the canonical version of a URL
|
99
99
|
test_files: []
|
data/Gemfile.local.example
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# Copy this file to a file named Gemfile.local to add these gems to your dev toolset
|
2
|
-
# Feel free to modify Gemfile.local to suit your own preferences
|
3
|
-
group :development do
|
4
|
-
gem 'github_changelog_generator'
|
5
|
-
gem 'gem-release'
|
6
|
-
gem 'guard'
|
7
|
-
gem 'guard-rspec'
|
8
|
-
gem 'guard-rubocop'
|
9
|
-
gem 'listen', '~> 3.0', '< 3.1' # Dependency of guard, 3.1 requires Ruby 2.2+
|
10
|
-
gem 'rake'
|
11
|
-
gem 'rubocop'
|
12
|
-
end
|