url_common 0.1.3 → 0.1.6
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/Gemfile.lock +1 -1
- data/lib/url_common/version.rb +1 -1
- data/lib/url_common.rb +38 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cc0c6794570b0acf1abb05d0650f7103669a3e07423344b98cf7d950368a638
|
4
|
+
data.tar.gz: 6bde7b252e4e4f0dab5d224fc737f50dc147cf6471947721f98a0da1e868369e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8293201992fc1dc914343268ca104416d06115b16b67281a66fac8f7af00f365b7de4a94c9e0b3a22308d744b581fc1f83fe48b050565ab639146bf84cd9b145
|
7
|
+
data.tar.gz: 63295ed84b0433a5bc22ca93b3b4701d6c77c7e9c5f0dba2a479072bc7b25fcac29b81a1f820605d7687da525735735b691eb00e11e05927e9ff0a21b2a77fb3
|
data/Gemfile.lock
CHANGED
data/lib/url_common/version.rb
CHANGED
data/lib/url_common.rb
CHANGED
@@ -56,6 +56,9 @@ module UrlCommon
|
|
56
56
|
# return parts.host.gsub(/^www./,'')
|
57
57
|
# end
|
58
58
|
|
59
|
+
#
|
60
|
+
# Designed to get just the domain without the WWW
|
61
|
+
#
|
59
62
|
def self.get_base_domain(url)
|
60
63
|
#debugger if url =~ /c06rh22whx1g/
|
61
64
|
begin
|
@@ -68,10 +71,24 @@ module UrlCommon
|
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
74
|
+
# designed to get the root of the domain i.e. elias.slack.com => slack.com
|
75
|
+
def self.get_root_domain(url)
|
76
|
+
begin
|
77
|
+
url = url.gsub(/ /,'%20')
|
78
|
+
url_parts = URI.parse(url)
|
79
|
+
host_parts = url_parts.host.split('.')
|
80
|
+
rescue StandardError => e
|
81
|
+
fu = Fuzzyurl.from_string(url)
|
82
|
+
host_parts = fu.hostname.split('.')
|
83
|
+
end
|
84
|
+
return "#{host_parts[host_parts.size - 2]}.#{host_parts.last}"
|
85
|
+
end
|
86
|
+
|
71
87
|
def self.join(base, rest, debug = false)
|
72
88
|
return URI.join(base, rest).to_s
|
73
89
|
end
|
74
90
|
|
91
|
+
# UrlCommon.url_no_www("https://www.youtube.com/watch?v=4Mj_zDw21xY")
|
75
92
|
def self.url_no_www(url)
|
76
93
|
parts = Fuzzyurl.new(url)
|
77
94
|
if parts.query
|
@@ -542,5 +559,26 @@ module UrlCommon
|
|
542
559
|
|
543
560
|
return UrlCommon.select_best_rssurl_from_rssurls(results)
|
544
561
|
end
|
562
|
+
|
563
|
+
#based on this approach: https://medium.com/@sparkboldstudio/building-a-url-shortener-rails-app-96db60d3bf9d
|
564
|
+
#def self.generate_short_fid
|
565
|
+
#def self.create_fid
|
566
|
+
def self.generate_fid
|
567
|
+
rand(36**8).to_s(36)
|
568
|
+
end
|
569
|
+
|
570
|
+
def self.sanitize(long_url, url_base)
|
571
|
+
long_url.strip!
|
572
|
+
sanitize_url = self.long_url.downcase.gsub(/(https?:\/\/)|(www\.)/,"")
|
573
|
+
#"http://#{sanitize_url}"
|
574
|
+
url_base + sanitize_url
|
575
|
+
end
|
576
|
+
|
577
|
+
# todo expand on this by checking to make sure it doesn't call again
|
578
|
+
# should be fine but ttfn
|
579
|
+
def self.create_permalink(tbl, fld, url)
|
580
|
+
short_url = UrlCommon.generate_short_url
|
581
|
+
sanitized_url = UrlCommon.sanitize(url, "https://pullquotes.io/pull_quotes/")
|
582
|
+
end
|
545
583
|
|
546
584
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: url_common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Johnson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fuzzyurl
|