BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
url_sanitizer.rb
lib/gitlab/url_sanitizer.rb
+8
-7
No files found.
lib/gitlab/url_sanitizer.rb
View file @
545b92af
module
Gitlab
module
Gitlab
class
UrlSanitizer
class
UrlSanitizer
attr_reader
:valid
alias_method
:valid?
,
:valid
def
self
.
sanitize
(
content
)
def
self
.
sanitize
(
content
)
regexp
=
URI
::
Parser
.
new
.
make_regexp
([
'http'
,
'https'
,
'ssh'
,
'git'
])
regexp
=
URI
::
Parser
.
new
.
make_regexp
([
'http'
,
'https'
,
'ssh'
,
'git'
])
content
.
gsub
(
regexp
)
{
|
url
|
new
(
url
).
masked_url
}
content
.
gsub
(
regexp
)
{
|
url
|
new
(
url
).
masked_url
}
end
end
def
self
.
valid?
(
url
)
Addressable
::
URI
.
parse
(
url
.
strip
)
true
rescue
Addressable
::
URI
::
InvalidURIError
false
end
def
initialize
(
url
,
credentials:
nil
)
def
initialize
(
url
,
credentials:
nil
)
@valid
=
true
@url
=
Addressable
::
URI
.
parse
(
url
.
strip
)
@url
=
Addressable
::
URI
.
parse
(
url
.
strip
)
@credentials
=
credentials
@credentials
=
credentials
rescue
Addressable
::
URI
::
InvalidURIError
@valid
=
false
raise
end
end
def
sanitized_url
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