librariesio-url-parser 1.0.8 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +8 -8
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/lib/librariesio-url-parser.rb +1 -1
- data/lib/url_parser.rb +32 -6
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13dcf367366e2bb9727f9e810ad38a9b6cb41eecf1cfb9a3b2d655067acf6e73
|
4
|
+
data.tar.gz: ca7a9fc70d37d58839af903d2905c60dbf38fb3adc502027eef54a6a5f2ffc92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f845dfec84e2d285a9f4a07e62df8d2de1b6a8c9ddf389449f964c7e2522fbbfa017553049898a1d4febe4fa457830de5af53808c29b1a9f3805bd80840ea66
|
7
|
+
data.tar.gz: e77275f149adcbe4c7676d494bd124ba1379f262673d21a997aed7788d72c3b86fedd8ae7e000110404ddba8f96d1c4013149e4a8e0a08dcda047383b7f8c55e
|
data/.circleci/config.yml
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
version: 2.1
|
2
2
|
orbs:
|
3
|
-
ruby: circleci/ruby@1.
|
3
|
+
ruby: circleci/ruby@2.1.3
|
4
4
|
|
5
5
|
jobs:
|
6
6
|
test:
|
7
7
|
docker:
|
8
|
-
- image: cimg/ruby:
|
8
|
+
- image: cimg/ruby:3.1.5
|
9
9
|
executor: ruby/default
|
10
10
|
steps:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
- checkout
|
12
|
+
- run:
|
13
|
+
name: Which bundler?
|
14
|
+
command: bundle -v
|
15
|
+
- ruby/install-deps
|
16
|
+
- ruby/rspec-test
|
17
17
|
|
18
18
|
workflows:
|
19
19
|
version: 2.1
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.5
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
librariesio-url-parser (1.0.
|
4
|
+
librariesio-url-parser (1.0.10)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -40,7 +40,7 @@ DEPENDENCIES
|
|
40
40
|
rspec_junit_formatter (~> 0.5)
|
41
41
|
|
42
42
|
RUBY VERSION
|
43
|
-
ruby
|
43
|
+
ruby 3.1.5p252
|
44
44
|
|
45
45
|
BUNDLED WITH
|
46
46
|
2.1.4
|
data/lib/url_parser.rb
CHANGED
@@ -11,13 +11,16 @@ class URLParser
|
|
11
11
|
@url = url.to_s.dup
|
12
12
|
end
|
13
13
|
|
14
|
+
# Clean the URL and format the path segments after the domain
|
15
|
+
#
|
16
|
+
# @return String Path segments after the domain joined by a "/"
|
14
17
|
def parse
|
15
18
|
return nil unless parseable?
|
16
19
|
|
17
20
|
if url = extractable_early?
|
18
21
|
url
|
19
22
|
else
|
20
|
-
clean_url
|
23
|
+
clean_url!
|
21
24
|
format_url
|
22
25
|
end
|
23
26
|
end
|
@@ -39,6 +42,10 @@ class URLParser
|
|
39
42
|
end
|
40
43
|
end
|
41
44
|
|
45
|
+
# Clean and parse the URL string returning all path segments following
|
46
|
+
# the domain.
|
47
|
+
#
|
48
|
+
# @return String Domain with URL path segments appended
|
42
49
|
def parse_to_full_url
|
43
50
|
path = parse
|
44
51
|
return nil if path.nil? || path.empty?
|
@@ -46,13 +53,17 @@ class URLParser
|
|
46
53
|
[full_domain, path].join('/')
|
47
54
|
end
|
48
55
|
|
56
|
+
# Clean and parse the URL string returning the first path following the domain.
|
57
|
+
#
|
58
|
+
# @return [String, nil] Domain with the lone user path segment appended. If the path resolved
|
59
|
+
# to more than one segment nil is returned since it is considered an invalid URL for a user.
|
49
60
|
def parse_to_full_user_url
|
50
61
|
return nil unless parseable?
|
51
62
|
|
52
|
-
|
53
|
-
return nil unless
|
63
|
+
clean_url!
|
64
|
+
return nil unless url.length == 1
|
54
65
|
|
55
|
-
[full_domain,
|
66
|
+
[full_domain, url].join('/')
|
56
67
|
end
|
57
68
|
|
58
69
|
def self.case_sensitive?
|
@@ -80,7 +91,12 @@ class URLParser
|
|
80
91
|
|
81
92
|
attr_accessor :url
|
82
93
|
|
83
|
-
|
94
|
+
# Clean up the string URL to find the non domain pieces of the URL and pass back
|
95
|
+
# to the specific parser class.
|
96
|
+
##
|
97
|
+
# @return [Array<String>, nil] Array of URL path segments following the domain or nil if the
|
98
|
+
# URL string does not contain the valid domain name.
|
99
|
+
def clean_url!
|
84
100
|
remove_whitespace
|
85
101
|
remove_quotes
|
86
102
|
remove_brackets
|
@@ -100,8 +116,18 @@ class URLParser
|
|
100
116
|
remove_git_scheme
|
101
117
|
remove_extra_segments
|
102
118
|
remove_git_extension
|
119
|
+
|
120
|
+
# url should have been transformed to an array during the various method calls
|
121
|
+
# The method is transforming the initialized url in place so any callers should
|
122
|
+
# reference url directly instead of expecting a return here.
|
123
|
+
url
|
103
124
|
end
|
104
125
|
|
126
|
+
# Join URL path segments for owner and repository name together with a "/" character.
|
127
|
+
#
|
128
|
+
#
|
129
|
+
# @return [String, nil] URL path segments joined by "/" or nil if there are not separate owner and
|
130
|
+
# repository name segments.
|
105
131
|
def format_url
|
106
132
|
return nil if url.nil?
|
107
133
|
return nil unless url.length == 2
|
@@ -136,7 +162,7 @@ class URLParser
|
|
136
162
|
def extractable_early?
|
137
163
|
return false if website_url?
|
138
164
|
|
139
|
-
match = url.match(/([\w
|
165
|
+
match = url.match(/([\w\.\@\:\-\~]+)\.#{domain_regex}\/([\w\.\@\:\-\~]+)/i)
|
140
166
|
if match && match.length == 4
|
141
167
|
return "#{match[1]}/#{match[3]}"
|
142
168
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: librariesio-url-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Pace
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.14.1
|
69
|
-
description:
|
69
|
+
description:
|
70
70
|
email:
|
71
71
|
- matt.pace@tidelift.com
|
72
72
|
executables: []
|
@@ -99,7 +99,7 @@ licenses:
|
|
99
99
|
- AGPL-3.0
|
100
100
|
metadata:
|
101
101
|
rubygems_mfa_required: 'true'
|
102
|
-
post_install_message:
|
102
|
+
post_install_message:
|
103
103
|
rdoc_options: []
|
104
104
|
require_paths:
|
105
105
|
- lib
|
@@ -114,8 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
rubygems_version: 3.
|
118
|
-
signing_key:
|
117
|
+
rubygems_version: 3.3.27
|
118
|
+
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Parse the URL for various repositories tracked by libraries.io
|
121
121
|
test_files: []
|