mirror of
https://github.com/neocities/neocities.git
synced 2025-06-27 14:44:35 +02:00
punycode support for domains, validate for registered domains
This commit is contained in:
parent
19638ff712
commit
fda95b7f07
6 changed files with 22 additions and 7 deletions
|
@ -812,6 +812,14 @@ class Site < Sequel::Model
|
|||
# super
|
||||
# end
|
||||
|
||||
def domain=(domain)
|
||||
super SimpleIDN.to_ascii(domain)
|
||||
end
|
||||
|
||||
def domain
|
||||
SimpleIDN.to_unicode values[:domain]
|
||||
end
|
||||
|
||||
def validate
|
||||
super
|
||||
|
||||
|
@ -864,15 +872,10 @@ class Site < Sequel::Model
|
|||
end
|
||||
|
||||
if !values[:domain].nil? && !values[:domain].empty?
|
||||
|
||||
if values[:domain] =~ /neocities\.org/ || values[:domain] =~ /neocitiesops\.net/
|
||||
errors.add :domain, "Domain is already being used.. by Neocities."
|
||||
end
|
||||
|
||||
if !(values[:domain] =~ /^[a-zA-Z0-9.-]+\.[a-zA-Z0-9]+$/i) || values[:domain].length > 90
|
||||
errors.add :domain, "Domain provided is not valid. Must take the form of domain.com"
|
||||
end
|
||||
|
||||
site = Site[domain: values[:domain]]
|
||||
if !site.nil? && site.id != self.id
|
||||
errors.add :domain, "Domain provided is already being used by another site, please choose another."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue