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
a5abec90
Commit
a5abec90
authored
Jun 20, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix addressable url validator
parent
6e7a4297
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
app/validators/addressable_url_validator.rb
app/validators/addressable_url_validator.rb
+7
-7
No files found.
app/validators/addressable_url_validator.rb
View file @
a5abec90
# UrlValidator
#
Addressable
UrlValidator
#
# Custom validator for URLs.
# Custom validator for URLs.
This is a
#
# By default, only URLs for
the HTTP(S)
protocols will be considered valid.
# By default, only URLs for
http, https, ssh, and git
protocols will be considered valid.
# Provide a `:protocols` option to configure accepted protocols.
#
# Example:
#
# class User < ActiveRecord::Base
# validates :personal_url, url: true
# validates :personal_url,
addressable_
url: true
#
# validates :ftp_url, url: { protocols: %w(ftp) }
# validates :ftp_url,
addressable_
url: { protocols: %w(ftp) }
#
# validates :git_url, url: { protocols: %w(http https ssh git) }
# validates :git_url,
addressable_
url: { protocols: %w(http https ssh git) }
# end
#
class
AddressableUrlValidator
<
ActiveModel
::
EachValidator
...
...
@@ -39,7 +39,7 @@ class AddressableUrlValidator < ActiveModel::EachValidator
end
def
valid_uri?
(
value
)
Addressable
::
URI
.
parse
(
strip
).
is_a?
(
Addressable
::
URI
)
Addressable
::
URI
.
parse
(
value
).
is_a?
(
Addressable
::
URI
)
end
def
valid_protocol?
(
value
)
...
...
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