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
Boxiang Sun
gitlab-ce
Commits
99f7b6d2
Commit
99f7b6d2
authored
Jul 11, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spec and fix for sanitize method
parent
94e9d571
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
0 deletions
+8
-0
lib/gitlab/url_sanitizer.rb
lib/gitlab/url_sanitizer.rb
+2
-0
spec/lib/gitlab/url_sanitizer_spec.rb
spec/lib/gitlab/url_sanitizer_spec.rb
+6
-0
No files found.
lib/gitlab/url_sanitizer.rb
View file @
99f7b6d2
...
...
@@ -4,6 +4,8 @@ module Gitlab
regexp
=
URI
::
Parser
.
new
.
make_regexp
([
'http'
,
'https'
,
'ssh'
,
'git'
])
content
.
gsub
(
regexp
)
{
|
url
|
new
(
url
).
masked_url
}
rescue
Addressable
::
URI
::
InvalidURIError
content
.
gsub
(
regexp
,
''
)
end
def
self
.
valid?
(
url
)
...
...
spec/lib/gitlab/url_sanitizer_spec.rb
View file @
99f7b6d2
...
...
@@ -45,6 +45,12 @@ describe Gitlab::UrlSanitizer, lib: true do
expect
(
filtered_content
).
to
include
(
"user@server:project.git"
)
end
it
'returns an empty string for invalid URLs'
do
filtered_content
=
sanitize_url
(
'ssh://'
)
expect
(
filtered_content
).
to
include
(
"repository '' not found"
)
end
end
describe
'#sanitized_url'
do
...
...
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