url_canonicalize 1.0.0 → 1.0.2

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.
@@ -4,25 +4,31 @@ require 'uri'
4
4
  require 'addressable/uri'
5
5
  require 'net/http'
6
6
  require 'nokogiri'
7
+ require 'timeout'
7
8
 
8
9
  autoload :OpenSSL, 'openssl'
9
10
 
10
11
  # Core methods
11
12
  module URLCanonicalize
13
+ autoload :BoundedBody, 'url_canonicalize/bounded_body'
14
+ autoload :Destination, 'url_canonicalize/destination'
12
15
  autoload :Exception, 'url_canonicalize/exception'
13
16
  autoload :HTTP, 'url_canonicalize/http'
17
+ autoload :LinkHeader, 'url_canonicalize/link_header'
18
+ autoload :MediaType, 'url_canonicalize/media_type'
19
+ autoload :Options, 'url_canonicalize/options'
14
20
  autoload :Request, 'url_canonicalize/request'
15
21
  autoload :Response, 'url_canonicalize/response'
16
22
  autoload :URI, 'url_canonicalize/uri'
17
23
  autoload :VERSION, 'url_canonicalize/version'
18
24
 
19
25
  class << self
20
- def canonicalize(url)
21
- fetch(url).url
26
+ def canonicalize(url, **options)
27
+ fetch(url, **options).url
22
28
  end
23
29
 
24
- def fetch(url)
25
- URLCanonicalize::HTTP.new(url).fetch
30
+ def fetch(url, **options)
31
+ URLCanonicalize::HTTP.new(url, **options).fetch
26
32
  end
27
33
  end
28
34
  end
@@ -30,4 +36,3 @@ end
30
36
  require 'monkey_patches/uri'
31
37
  require 'monkey_patches/string'
32
38
  require 'monkey_patches/addressable/uri'
33
- require 'English' # Needed for $LAST_MATCH_INFO
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: url_canonicalize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominic Sayers
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-01-27 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: addressable
@@ -46,40 +45,35 @@ executables: []
46
45
  extensions: []
47
46
  extra_rdoc_files: []
48
47
  files:
49
- - ".codeclimate.yml"
50
- - ".github/workflows/codeql-analysis.yml"
51
- - ".gitignore"
52
- - ".hound.yml"
53
- - ".rspec"
54
- - ".rubocop.yml"
55
- - ".ruby-gemset"
56
- - ".travis.yml"
57
48
  - CHANGELOG.md
58
- - Gemfile
59
- - Gemfile.lock
60
- - Guardfile
61
49
  - LICENSE
62
50
  - README.md
63
- - Rakefile
64
- - circle.yml
51
+ - SECURITY.md
65
52
  - lib/monkey_patches/addressable/uri.rb
66
53
  - lib/monkey_patches/string.rb
67
54
  - lib/monkey_patches/uri.rb
68
55
  - lib/url_canonicalize.rb
56
+ - lib/url_canonicalize/bounded_body.rb
57
+ - lib/url_canonicalize/destination.rb
69
58
  - lib/url_canonicalize/exception.rb
70
59
  - lib/url_canonicalize/http.rb
60
+ - lib/url_canonicalize/link_header.rb
61
+ - lib/url_canonicalize/media_type.rb
62
+ - lib/url_canonicalize/options.rb
71
63
  - lib/url_canonicalize/request.rb
72
64
  - lib/url_canonicalize/response.rb
73
65
  - lib/url_canonicalize/uri.rb
74
66
  - lib/url_canonicalize/version.rb
75
- - renovate.json
76
- - url_canonicalize.gemspec
77
67
  homepage: https://github.com/dominicsayers/url_canonicalize
78
68
  licenses:
79
69
  - MIT
80
70
  metadata:
71
+ bug_tracker_uri: https://github.com/dominicsayers/url_canonicalize/issues
72
+ changelog_uri: https://github.com/dominicsayers/url_canonicalize/blob/main/CHANGELOG.md
73
+ documentation_uri: https://www.rubydoc.info/gems/url_canonicalize
74
+ homepage_uri: https://github.com/dominicsayers/url_canonicalize
75
+ source_code_uri: https://github.com/dominicsayers/url_canonicalize
81
76
  rubygems_mfa_required: 'true'
82
- post_install_message:
83
77
  rdoc_options: []
84
78
  require_paths:
85
79
  - lib
@@ -94,8 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
88
  - !ruby/object:Gem::Version
95
89
  version: '0'
96
90
  requirements: []
97
- rubygems_version: 3.4.6
98
- signing_key:
91
+ rubygems_version: 4.0.16
99
92
  specification_version: 4
100
93
  summary: Finds the canonical version of a URL
101
94
  test_files: []
data/.codeclimate.yml DELETED
@@ -1,25 +0,0 @@
1
- ---
2
- engines:
3
- duplication:
4
- enabled: true
5
- config:
6
- languages:
7
- - ruby
8
- - javascript
9
- - python
10
- - php
11
- fixme:
12
- enabled: true
13
- rubocop:
14
- enabled: true
15
- ratings:
16
- paths:
17
- - "**.inc"
18
- - "**.js"
19
- - "**.jsx"
20
- - "**.module"
21
- - "**.php"
22
- - "**.py"
23
- - "**.rb"
24
- exclude_paths:
25
- - spec/
@@ -1,70 +0,0 @@
1
- # For most projects, this workflow file will not need changing; you simply need
2
- # to commit it to your repository.
3
- #
4
- # You may wish to alter this file to override the set of languages analyzed,
5
- # or to provide custom queries or build logic.
6
- #
7
- # ******** NOTE ********
8
- # We have attempted to detect the languages in your repository. Please check
9
- # the `language` matrix defined below to confirm you have the correct set of
10
- # supported CodeQL languages.
11
- #
12
- name: "CodeQL"
13
-
14
- on:
15
- push:
16
- branches: [ main ]
17
- pull_request:
18
- # The branches below must be a subset of the branches above
19
- branches: [ main ]
20
- schedule:
21
- - cron: '28 12 * * 5'
22
-
23
- jobs:
24
- analyze:
25
- name: Analyze
26
- runs-on: ubuntu-latest
27
- permissions:
28
- actions: read
29
- contents: read
30
- security-events: write
31
-
32
- strategy:
33
- fail-fast: false
34
- matrix:
35
- language: [ 'ruby' ]
36
- # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
- # Learn more about CodeQL language support at https://git.io/codeql-language-support
38
-
39
- steps:
40
- - name: Checkout repository
41
- uses: actions/checkout@v4
42
-
43
- # Initializes the CodeQL tools for scanning.
44
- - name: Initialize CodeQL
45
- uses: github/codeql-action/init@v3
46
- with:
47
- languages: ${{ matrix.language }}
48
- # If you wish to specify custom queries, you can do so here or in a config file.
49
- # By default, queries listed here will override any specified in a config file.
50
- # Prefix the list here with "+" to use these queries and those in the config file.
51
- # queries: ./path/to/local/query, your-org/your-repo/queries@main
52
-
53
- # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54
- # If this step fails, then you should remove it and run the build manually (see below)
55
- - name: Autobuild
56
- uses: github/codeql-action/autobuild@v3
57
-
58
- # ℹ️ Command-line programs to run using the OS shell.
59
- # 📚 https://git.io/JvXDl
60
-
61
- # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62
- # and modify them (or add more) to build your code if your project
63
- # uses a compiled language
64
-
65
- #- run: |
66
- # make bootstrap
67
- # make release
68
-
69
- - name: Perform CodeQL Analysis
70
- uses: github/codeql-action/analyze@v3
data/.gitignore DELETED
@@ -1,53 +0,0 @@
1
- *.local
2
- *.gem
3
- *.rbc
4
- /.config
5
- /coverage/
6
- /InstalledFiles
7
- /pkg/
8
- /spec/reports/
9
- /spec/examples.txt
10
- /test/tmp/
11
- /test/version_tmp/
12
- /tmp/
13
-
14
- # Used by dotenv library to load environment variables.
15
- # .env
16
-
17
- ## Specific to RubyMotion:
18
- .dat*
19
- .repl_history
20
- build/
21
- *.bridgesupport
22
- build-iPhoneOS/
23
- build-iPhoneSimulator/
24
-
25
- ## Specific to RubyMotion (use of CocoaPods):
26
- #
27
- # We recommend against adding the Pods directory to your .gitignore. However
28
- # you should judge for yourself, the pros and cons are mentioned at:
29
- # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
30
- #
31
- # vendor/Pods/
32
-
33
- ## Documentation cache and generated files:
34
- /.yardoc/
35
- /_yardoc/
36
- /doc/
37
- /rdoc/
38
-
39
- ## Environment normalization:
40
- /.bundle/
41
- /vendor/bundle
42
- /lib/bundler/man/
43
-
44
- # for a library or gem, you might want to ignore these files since the code is
45
- # intended to run in multiple environments; otherwise, check them in:
46
- # Gemfile.lock
47
- .ruby-version
48
- .ruby-gemset
49
-
50
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
51
- .rvmrc
52
-
53
- .vscode/
data/.hound.yml DELETED
@@ -1,4 +0,0 @@
1
- ---
2
- ruby:
3
- enabled: true
4
- config_file: .rubocop.yml
data/.rspec DELETED
@@ -1,5 +0,0 @@
1
- --color
2
- --require spec_helper
3
- --profile
4
- --format progress
5
- --format RspecJunitFormatter --out <%= ENV.fetch('CIRCLE_TEST_REPORTS', 'tmp') %>/rspec/rspec.xml
data/.rubocop.yml DELETED
@@ -1,61 +0,0 @@
1
- ---
2
- AllCops:
3
- DisplayStyleGuide: true
4
- DisplayCopNames: true
5
- TargetRubyVersion: 3.1
6
- NewCops: enable
7
-
8
- Layout/DotPosition:
9
- Description: 'Checks the position of the dot in multi-line method calls.'
10
- EnforcedStyle: leading
11
- Enabled: true
12
-
13
- Layout/ExtraSpacing:
14
- Description: 'Do not use unnecessary spacing.'
15
- Enabled: true
16
-
17
- Layout/LineLength:
18
- Max: 120
19
- Exclude:
20
- - spec/**/*
21
-
22
- Lint/LiteralInInterpolation:
23
- Description: 'Avoid interpolating literals in strings'
24
- AutoCorrect: true
25
-
26
- Metrics/BlockLength:
27
- Exclude:
28
- - spec/**/*
29
-
30
- Metrics/ClassLength:
31
- CountComments: false # count full line comments?
32
- Max: 200
33
-
34
- Metrics/MethodLength:
35
- Max: 12
36
-
37
- Naming/FileName:
38
- Description: 'Use snake_case for source file names.'
39
- Enabled: true
40
-
41
- Style/ClassAndModuleChildren:
42
- Description: 'Checks style of children classes and modules.'
43
- EnforcedStyle: nested
44
- Enabled: true
45
-
46
- Style/Documentation:
47
- Description: 'Document classes and non-namespace modules.'
48
- Enabled: false
49
-
50
- Style/StringLiterals:
51
- EnforcedStyle: single_quotes
52
- Enabled: true
53
-
54
- Style/SymbolArray:
55
- Description: 'Use %i or %I for arrays of symbols.'
56
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-i'
57
- Enabled: false # Only available in Ruby 2.0+
58
-
59
- Style/TrailingCommaInArguments:
60
- EnforcedStyleForMultiline: no_comma
61
- Enabled: true
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- url_canonicalize
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- ---
2
- language: ruby
3
- rvm:
4
- - 3.1
5
- - 3.2
6
- - 3.3
7
- script:
8
- - rspec
data/Gemfile DELETED
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gemspec
6
-
7
- group :static_code_analysis do
8
- gem 'rubocop', require: false
9
- gem 'rubocop-rspec', require: false
10
- end
11
-
12
- group :test do
13
- gem 'coveralls-ruby', require: false
14
- gem 'rspec'
15
- gem 'rspec_junit_formatter'
16
- gem 'simplecov'
17
- gem 'webmock'
18
- end
19
-
20
- group :build do
21
- gem 'gem-release', require: false
22
- end
data/Gemfile.lock DELETED
@@ -1,110 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- url_canonicalize (1.0.0)
5
- addressable (~> 2)
6
- nokogiri (>= 1.13)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- addressable (2.8.6)
12
- public_suffix (>= 2.0.2, < 6.0)
13
- ast (2.4.2)
14
- coveralls-ruby (0.2.0)
15
- json (>= 1.8, < 3)
16
- simplecov (~> 0.16.1)
17
- term-ansicolor (~> 1.3)
18
- thor (>= 0.19.4, < 2.0)
19
- tins (~> 1.6)
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.1.0)
26
- json (2.7.1)
27
- language_server-protocol (3.17.0.3)
28
- mini_portile2 (2.8.5)
29
- nokogiri (1.13.10)
30
- mini_portile2 (~> 2.8.0)
31
- racc (~> 1.4)
32
- parallel (1.24.0)
33
- parser (3.3.0.5)
34
- ast (~> 2.4.1)
35
- racc
36
- public_suffix (4.0.7)
37
- racc (1.6.1)
38
- rainbow (3.1.1)
39
- regexp_parser (2.9.0)
40
- rexml (3.2.6)
41
- rspec (3.12.0)
42
- rspec-core (~> 3.12.0)
43
- rspec-expectations (~> 3.12.0)
44
- rspec-mocks (~> 3.12.0)
45
- rspec-core (3.12.2)
46
- rspec-support (~> 3.12.0)
47
- rspec-expectations (3.12.3)
48
- diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.12.0)
50
- rspec-mocks (3.12.6)
51
- diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.12.0)
53
- rspec-support (3.12.1)
54
- rspec_junit_formatter (0.6.0)
55
- rspec-core (>= 2, < 4, != 2.12.0)
56
- rubocop (1.60.2)
57
- json (~> 2.3)
58
- language_server-protocol (>= 3.17.0)
59
- parallel (~> 1.10)
60
- parser (>= 3.3.0.2)
61
- rainbow (>= 2.2.2, < 4.0)
62
- regexp_parser (>= 1.8, < 3.0)
63
- rexml (>= 3.2.5, < 4.0)
64
- rubocop-ast (>= 1.30.0, < 2.0)
65
- ruby-progressbar (~> 1.7)
66
- unicode-display_width (>= 2.4.0, < 3.0)
67
- rubocop-ast (1.30.0)
68
- parser (>= 3.2.1.0)
69
- rubocop-capybara (2.20.0)
70
- rubocop (~> 1.41)
71
- rubocop-factory_bot (2.25.1)
72
- rubocop (~> 1.41)
73
- rubocop-rspec (2.26.1)
74
- rubocop (~> 1.40)
75
- rubocop-capybara (~> 2.17)
76
- rubocop-factory_bot (~> 2.22)
77
- ruby-progressbar (1.13.0)
78
- simplecov (0.16.1)
79
- docile (~> 1.1)
80
- json (>= 1.8, < 3)
81
- simplecov-html (~> 0.10.0)
82
- simplecov-html (0.10.2)
83
- sync (0.5.0)
84
- term-ansicolor (1.7.1)
85
- tins (~> 1.0)
86
- thor (1.2.1)
87
- tins (1.31.0)
88
- sync
89
- unicode-display_width (2.5.0)
90
- webmock (3.19.1)
91
- addressable (>= 2.8.0)
92
- crack (>= 0.3.2)
93
- hashdiff (>= 0.4.0, < 2.0.0)
94
-
95
- PLATFORMS
96
- x86_64-linux
97
-
98
- DEPENDENCIES
99
- coveralls-ruby
100
- gem-release
101
- rspec
102
- rspec_junit_formatter
103
- rubocop
104
- rubocop-rspec
105
- simplecov
106
- url_canonicalize!
107
- webmock
108
-
109
- BUNDLED WITH
110
- 2.5.5
data/Guardfile DELETED
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- guard :rubocop do
4
- watch(/.+\.rb$/)
5
- watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
6
- end
7
-
8
- guard(
9
- :rspec,
10
- all_after_pass: false,
11
- all_on_start: false,
12
- cmd: 'NO_SIMPLECOV=true bundle exec rspec --fail-fast --format documentation'
13
- ) do
14
- watch(%r{spec/.+_spec\.rb$})
15
- watch(%r{lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
16
- watch('spec/spec_helper.rb') { 'spec' }
17
- watch(%r{^spec/support/.+\.rb$}) { 'spec' }
18
- end
data/Rakefile DELETED
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
data/circle.yml DELETED
@@ -1,29 +0,0 @@
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: ["3.1", "3.2", "3.3"]
data/renovate.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": [
4
- "config:recommended"
5
- ]
6
- }
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'url_canonicalize/version'
6
-
7
- Gem::Specification.new do |s|
8
- s.name = 'url_canonicalize'
9
- s.version = URLCanonicalize::VERSION
10
- s.authors = ['Dominic Sayers']
11
- s.email = ['dominic@sayers.cc']
12
- s.summary = 'Finds the canonical version of a URL'
13
- s.description = 'Rubygem that finds the canonical version of a URL by ' \
14
- 'providing #canonicalize methods for the String, URI::HTTP' \
15
- ', URI::HTTPS and Addressable::URI classes'
16
- s.homepage = 'https://github.com/dominicsayers/url_canonicalize'
17
- s.license = 'MIT'
18
-
19
- s.required_ruby_version = '>= 3.1.0'
20
-
21
- s.files = `git ls-files`.split($RS).grep_v(%r{^spec/})
22
-
23
- s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
- s.require_paths = ['lib']
25
-
26
- s.add_runtime_dependency 'addressable', '~> 2' # To normalize URLs
27
- s.add_runtime_dependency 'nokogiri', '>= 1.13' # To look for <link rel="canonical" ...> in HTML
28
- s.metadata['rubygems_mfa_required'] = 'true'
29
- end