Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
545b92af
Commit
545b92af
authored
Jun 30, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use class method
parent
5b893d60
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
lib/gitlab/url_sanitizer.rb
lib/gitlab/url_sanitizer.rb
+8
-7
No files found.
lib/gitlab/url_sanitizer.rb
View file @
545b92af
module
Gitlab
class
UrlSanitizer
attr_reader
:valid
alias_method
:valid?
,
:valid
def
self
.
sanitize
(
content
)
regexp
=
URI
::
Parser
.
new
.
make_regexp
([
'http'
,
'https'
,
'ssh'
,
'git'
])
content
.
gsub
(
regexp
)
{
|
url
|
new
(
url
).
masked_url
}
end
def
self
.
valid?
(
url
)
Addressable
::
URI
.
parse
(
url
.
strip
)
true
rescue
Addressable
::
URI
::
InvalidURIError
false
end
def
initialize
(
url
,
credentials:
nil
)
@valid
=
true
@url
=
Addressable
::
URI
.
parse
(
url
.
strip
)
@credentials
=
credentials
rescue
Addressable
::
URI
::
InvalidURIError
@valid
=
false
raise
end
def
sanitized_url
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment