Fix link in structure when the item is a link
Add internal links creation
This commit is contained in:
1 parent
c85629d3b3
commit
74b2bbf4b7
3 files changed
+55
-4
No files matched your search
+2
-2
@@ -2,7 +2,7 @@ class Link < Item
|
||||
|
||||
field :url
|
||||
|
||||
validates :url, :presence => true, :format => /^(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?/i
|
||||
validates :url, :presence => true, :format => /^(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))|localhost(:[0-9]{1,5})?(\/.*)?/i
|
||||
|
||||
before_validation :add_http
|
||||
|
||||
@@ -13,7 +13,7 @@ class Link < Item
|
||||
protected
|
||||
|
||||
def add_http
|
||||
unless self.url[/^http:\/\//] || self.url[/^https:\/\//]
|
||||
unless self.url[/^(http|https):\/\//] || self.url.blank?
|
||||
self.url = 'http://' + self.url
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user