true_url 0.0.4 → 0.0.5
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 +5 -5
- data/.gitignore +46 -11
- data/Gemfile +2 -2
- data/README.md +0 -3
- data/lib/true_url.rb +8 -8
- data/lib/true_url/fetch.rb +1 -1
- data/lib/true_url/version.rb +1 -1
- data/spec/spec_helper.rb +0 -2
- data/spec/true_url_spec.rb +9 -12
- data/true_url.gemspec +4 -4
- metadata +4 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1d888ed0c4998f8faecce67df159703c5d9351d900557b1e36ef5a4bcb7a1b33
|
4
|
+
data.tar.gz: ca9759d5ef980784927afbccbe54c14a3d9aa05f5f688245f44629e69b9e096f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b45a4e1d57a08db0dd8037d00d56ae1fb01987d089fa23a37817e37edf78def8afbf59376599fce80bbcc722b5ed423a8c9c9b98757e196a0127a9c611374ce3
|
7
|
+
data.tar.gz: f33859132df9aa8591882064dd1e2c1e4c75fbf920c6e4bf344780e12a23e358974462661ebfdccb1a6242388f95bb56cccea2e043b2229e90939540014188b2
|
data/.gitignore
CHANGED
@@ -1,15 +1,50 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
/_yardoc/
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
5
4
|
/coverage/
|
6
|
-
/
|
5
|
+
/InstalledFiles
|
7
6
|
/pkg/
|
8
7
|
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
9
11
|
/tmp/
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -43,6 +43,3 @@ puts x.canonical # => http://www.prdaily.com/Main/Articles/3_essential_skills_fo
|
|
43
43
|
* [PostRank URI](https://github.com/postrank-labs/postrank-uri)
|
44
44
|
* [Linkr](https://github.com/bbc/linkr)
|
45
45
|
* [Pope](https://github.com/socksforrobots/pope)
|
46
|
-
|
47
|
-
## License
|
48
|
-
**TrueURL** is released under the [MIT license](MIT-LICENSE).
|
data/lib/true_url.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
autoload :Fetch, 'true_url/fetch'
|
1
|
+
require 'true_url/context'
|
2
|
+
require 'true_url/fetch'
|
3
|
+
require 'true_url/strategy'
|
4
|
+
require 'true_url/version'
|
6
5
|
|
6
|
+
class TrueURL
|
7
7
|
attr_accessor :context, :strategies
|
8
8
|
|
9
9
|
OPTIONS = {
|
@@ -11,7 +11,7 @@ class TrueURL
|
|
11
11
|
fetch: true # Whether to fetch the URL
|
12
12
|
}.freeze
|
13
13
|
|
14
|
-
QUERY_VALUES_TO_REMOVE = %w
|
14
|
+
QUERY_VALUES_TO_REMOVE = %w[
|
15
15
|
utm_source
|
16
16
|
utm_medium
|
17
17
|
utm_term
|
@@ -21,7 +21,7 @@ class TrueURL
|
|
21
21
|
awesm
|
22
22
|
xtor
|
23
23
|
PHPSESSID
|
24
|
-
|
24
|
+
].freeze
|
25
25
|
|
26
26
|
def initialize(url, options = {})
|
27
27
|
@context = TrueURL::Context.new(url, OPTIONS.merge(options))
|
@@ -83,7 +83,7 @@ class TrueURL
|
|
83
83
|
return false if @context.working_url.host.nil?
|
84
84
|
|
85
85
|
# We only support HTTP or HTTPS
|
86
|
-
%w
|
86
|
+
%w[http https].include?(@context.working_url.scheme)
|
87
87
|
end
|
88
88
|
|
89
89
|
def scheme_override
|
data/lib/true_url/fetch.rb
CHANGED
data/lib/true_url/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'coveralls'
|
2
2
|
Coveralls.wear!
|
3
3
|
|
4
|
-
require 'true_url'
|
5
|
-
|
6
4
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
7
5
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
8
6
|
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
data/spec/true_url_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'true_url'
|
2
2
|
|
3
3
|
def gc(unclean_url, options = {})
|
4
4
|
TrueURL.new(unclean_url, options).canonical
|
@@ -32,8 +32,8 @@ describe TrueURL do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'supports direct channel links' do
|
35
|
-
t = 'https://www.youtube.com/
|
36
|
-
expect(gc('https://www.youtube.com/
|
35
|
+
t = 'https://www.youtube.com/channel/UCaWd5_7JhbQBe4dknZhsHJg'
|
36
|
+
expect(gc('https://www.youtube.com/user/WatchMojo')).to eq t
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'supports retrieving embed links as attributes' do
|
@@ -132,7 +132,7 @@ describe TrueURL do
|
|
132
132
|
|
133
133
|
describe 'URL Shorteners' do
|
134
134
|
it 'should work with t.co' do
|
135
|
-
t = '
|
135
|
+
t = 'https://www.prdaily.com/Main/Articles/3_essential_skills_for_todays_PR_pro__18404.aspx'
|
136
136
|
expect(gc('http://t.co/fvaGuRa5Za')).to eq t
|
137
137
|
expect(gc('https://t.co/fvaGuRa5Za')).to eq t
|
138
138
|
end
|
@@ -155,8 +155,8 @@ describe TrueURL do
|
|
155
155
|
|
156
156
|
describe 'WordPress' do
|
157
157
|
it 'supports missing trailing slashes' do
|
158
|
-
t = '
|
159
|
-
expect(gc('
|
158
|
+
t = 'https://wowjapan.asia/2015/04/anime-gargantia-on-the-verdurous-planet-2nd-season-cancelled/'
|
159
|
+
expect(gc('https://wowjapan.asia/2015/04/anime-gargantia-on-the-verdurous-planet-2nd-season-cancelled')).to eq t
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
@@ -169,13 +169,13 @@ describe TrueURL do
|
|
169
169
|
|
170
170
|
describe 'Other Scenarios' do
|
171
171
|
it 'supports missing schemes' do
|
172
|
-
t = '
|
172
|
+
t = 'https://wowjapan.asia/2015/04/anime-gargantia-on-the-verdurous-planet-2nd-season-cancelled/'
|
173
173
|
expect(gc('//wowjapan.asia/2015/04/anime-gargantia-on-the-verdurous-planet-2nd-season-cancelled/')).to eq t
|
174
174
|
end
|
175
175
|
|
176
176
|
it 'supports scheme override' do
|
177
|
-
t = '
|
178
|
-
expect(gc('//wowjapan.asia/2015/04/anime-gargantia-on-the-verdurous-planet-2nd-season-cancelled/', scheme_override: '
|
177
|
+
t = 'http://wowjapan.asia/2015/04/anime-gargantia-on-the-verdurous-planet-2nd-season-cancelled/'
|
178
|
+
expect(gc('//wowjapan.asia/2015/04/anime-gargantia-on-the-verdurous-planet-2nd-season-cancelled/', scheme_override: 'http')).to eq t
|
179
179
|
end
|
180
180
|
|
181
181
|
it 'supports CDJapan' do
|
@@ -189,9 +189,6 @@ describe TrueURL do
|
|
189
189
|
end
|
190
190
|
|
191
191
|
it 'supports URLs with escapable characters' do
|
192
|
-
t = 'http://goboiano.com/news/2568-attack-on-titan%2527s-first-live-action-trailer-finally-launches'
|
193
|
-
expect(gc("http://media.goboiano.com/news/2568-attack-on-titan's-first-live-action-trailer-finally-launches")).to eq t
|
194
|
-
|
195
192
|
t = 'http://randomc.net/image/Kekkai%20Sensen/Kekkai%20Sensen%20-%2001%20-%20Large%2001.jpg'
|
196
193
|
expect(gc('http://randomc.net/image/Kekkai Sensen/Kekkai Sensen - 01 - Large 01.jpg')).to eq t
|
197
194
|
end
|
data/true_url.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.authors = ['Jonathan Wong']
|
7
7
|
spec.email = ['jonathan@armchairtheorist.com']
|
8
8
|
spec.summary = 'A multi-strategy approach to find the absolutely cleanest and most likely canonical URL of any given URL.'
|
9
|
-
spec.homepage = '
|
9
|
+
spec.homepage = 'https://github.com/armchairtheorist/true_url'
|
10
10
|
spec.license = 'MIT'
|
11
11
|
|
12
12
|
spec.files = `git ls-files`.split("\n")
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.add_development_dependency 'rspec', '~> 0'
|
17
17
|
spec.add_development_dependency 'rake', '~> 0'
|
18
18
|
|
19
|
-
spec.add_runtime_dependency 'addressable', '
|
20
|
-
spec.add_runtime_dependency 'http', '
|
21
|
-
spec.add_runtime_dependency 'nokogiri', '
|
19
|
+
spec.add_runtime_dependency 'addressable', '>= 2.4.0'
|
20
|
+
spec.add_runtime_dependency 'http', '>= 2.1.0'
|
21
|
+
spec.add_runtime_dependency 'nokogiri', '>= 1.6.8'
|
22
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: true_url
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Wong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -42,9 +42,6 @@ dependencies:
|
|
42
42
|
name: addressable
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2.4'
|
48
45
|
- - ">="
|
49
46
|
- !ruby/object:Gem::Version
|
50
47
|
version: 2.4.0
|
@@ -52,9 +49,6 @@ dependencies:
|
|
52
49
|
prerelease: false
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
54
51
|
requirements:
|
55
|
-
- - "~>"
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: '2.4'
|
58
52
|
- - ">="
|
59
53
|
- !ruby/object:Gem::Version
|
60
54
|
version: 2.4.0
|
@@ -62,9 +56,6 @@ dependencies:
|
|
62
56
|
name: http
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '2.1'
|
68
59
|
- - ">="
|
69
60
|
- !ruby/object:Gem::Version
|
70
61
|
version: 2.1.0
|
@@ -72,9 +63,6 @@ dependencies:
|
|
72
63
|
prerelease: false
|
73
64
|
version_requirements: !ruby/object:Gem::Requirement
|
74
65
|
requirements:
|
75
|
-
- - "~>"
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '2.1'
|
78
66
|
- - ">="
|
79
67
|
- !ruby/object:Gem::Version
|
80
68
|
version: 2.1.0
|
@@ -82,9 +70,6 @@ dependencies:
|
|
82
70
|
name: nokogiri
|
83
71
|
requirement: !ruby/object:Gem::Requirement
|
84
72
|
requirements:
|
85
|
-
- - "~>"
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '1.6'
|
88
73
|
- - ">="
|
89
74
|
- !ruby/object:Gem::Version
|
90
75
|
version: 1.6.8
|
@@ -92,9 +77,6 @@ dependencies:
|
|
92
77
|
prerelease: false
|
93
78
|
version_requirements: !ruby/object:Gem::Requirement
|
94
79
|
requirements:
|
95
|
-
- - "~>"
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '1.6'
|
98
80
|
- - ">="
|
99
81
|
- !ruby/object:Gem::Version
|
100
82
|
version: 1.6.8
|
@@ -127,7 +109,7 @@ files:
|
|
127
109
|
- spec/spec_helper.rb
|
128
110
|
- spec/true_url_spec.rb
|
129
111
|
- true_url.gemspec
|
130
|
-
homepage:
|
112
|
+
homepage: https://github.com/armchairtheorist/true_url
|
131
113
|
licenses:
|
132
114
|
- MIT
|
133
115
|
metadata: {}
|
@@ -147,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
129
|
version: '0'
|
148
130
|
requirements: []
|
149
131
|
rubyforge_project:
|
150
|
-
rubygems_version: 2.
|
132
|
+
rubygems_version: 2.7.6
|
151
133
|
signing_key:
|
152
134
|
specification_version: 4
|
153
135
|
summary: A multi-strategy approach to find the absolutely cleanest and most likely
|