# User Preference 'Website' does not allow new TLDs

**URL:** https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931
**Category:** Bug
**Created:** [September 9, 2016, 1:08pm UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931 "2016-09-09T13:08:57Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![JamesNorth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamesnorth/32/283740_2.png) [@JamesNorth](https://meta.discourse.org/u/JamesNorth)
#### Post date: [September 9, 2016, 1:08pm UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/1 "2016-09-09T13:08:57Z")

</div>

Even though Discourse is hosted on my new TLD domain ‘jamesnorth.productions’, it will not allow the website ‘[http://jamesnorth.productions](http://jamesnorth.productions)’ in the user preferences.

It says that the website is invalid.

Version v1.7.0.beta3 +100

 ![](https://global.discourse-cdn.com/meta/original/3X/d/7/d76c7c0f50b04d37fe208be1136ebbc13d935a80.png)

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [September 9, 2016, 1:50pm UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/2 "2016-09-09T13:50:02Z")

</div>

Here is the relevant line

> <https://github.com/discourse/discourse/blob/1f5325e3f03db06aff71f1e1d9343ee2b7f21ed2/app/models/user_profile.rb#L4>

Changing the 2,10 to 2, would permit any length, but not sure if that would be the right modification for this.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [September 9, 2016, 8:28pm UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/3 "2016-09-09T20:28:57Z")

</div>

> [@cpradio](#):
>
> Changing the 2,10 to 2, would permit any length, but not sure if that would be the right modification for this.

I have many questions about that RE.

Here’s a fragment to match a DNS label (other than top-level):

`/[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?/i`

What it is doing:

- a label must start with a letter or number: `[a-z0-9]`
- you can have letters, numbers and hyphens in the middle: `[a-z0-9-]{0,61}`
  - double hyphens _are_ allowed
  - a label can be up to 63 characters long

- a label must end with a letter or number: `[a-z0-9]`

The rules for a TLD are the same, except that all numeric is not allowed.

No number in first position (one character label okay): `/([a-z]([a-z0-9-]{0,61}[a-z0-9])?)/i`  
No number in last position (two character minimum): `/[a-z0-9][a-z0-9-]{0,61}[a-z]/i`  
At least one letter in middle part (hacky for making RE readable): `/[a-z0-9][a-z0-9-]{1,30}[a-z]([a-z0-9-]{0,30}[a-z0-9])?/i`

> **hacky**
>
> The hacky one could be rewritten to all compliant strings, but it is ugly to enforce a letter somewhere while also enforcing a length restriction. There will be a ton of `|`s in the proper answer.

Combined hostname RE: `(labelpart\.)+(tldpart1|tldpart2|tldpart3)` :

```plaintext
/([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+(([a-z]([a-z0-9-]{0,61}[a-z0-9])?)|[a-z0-9][a-z0-9-]{0,61}[a-z]|[a-z0-9][a-z0-9-]{1,30}[a-z]([a-z0-9-]{0,30}[a-z0-9])?/i

```

And final combined WEBSITE\_REGEXP:

```ruby
WEBSITE_REGEXP = /(^$)|(^(http|https):\/\/([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+(([a-z]([a-z0-9-]{0,61}[a-z0-9])?)|[a-z0-9][a-z0-9-]{0,61}[a-z]|[a-z0-9][a-z0-9-]{1,30}[a-z]([a-z0-9-]{0,30}[a-z0-9])?\/.*)?$)/ix

```

(The syntax highlighter gets confused by the “Combined” line.)

Does /x to ruby mean the same as /x to perl? If so, in-line comments and a reformat should be added.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [September 10, 2016, 1:33am UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/4 "2016-09-10T01:33:14Z")

</div>

> [@elijah](#):
>
> The rules for a TLD are the same, except that all numeric is not allowed.

It occurs to me that I stated that correctly, but did not code it correctly. When the dot-com billionaire who remembers his script kiddie roots registers the 1-3-3-7 TLD (for the ‘leet’ email address of `i@m.1-3-3-7`), TLD part 3 above would find no letters and deny it. The fix should be obvious.

---

<div class="post-metadata">

### Author: ![JamesNorth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamesnorth/32/283740_2.png) [@JamesNorth](https://meta.discourse.org/u/JamesNorth)
#### Post date: [October 24, 2016, 8:52am UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/5 "2016-10-24T08:52:03Z")

</div>

Just giving this one a bit of a bump.

It seems as though the admin area **does allow** new TLDs in `company domain` and in `contact email`.

Are they being validated though, or do they allow anything?

If the former, perhaps whatever that validation is will work perfectly well in the user `preferences` area.

---

<div class="post-metadata">

### Author: ![JamesNorth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamesnorth/32/283740_2.png) [@JamesNorth](https://meta.discourse.org/u/JamesNorth)
#### Post date: [March 1, 2017, 1:10pm UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/6 "2017-03-01T13:10:59Z")

</div>

Bumping this one again.

Still cannot change `website` parameter in user profile to new TLDs - tells user the address is invalid.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [March 2, 2017, 1:05am UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/7 "2017-03-02T01:05:33Z")

</div>

Sure @falco can you add this one to your list please? We should have centralized logic for this check..

---

<div class="post-metadata">

### Author: ![JamesNorth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamesnorth/32/283740_2.png) [@JamesNorth](https://meta.discourse.org/u/JamesNorth)
#### Post date: [June 13, 2017, 1:34pm UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/8 "2017-06-13T13:34:06Z")

</div>

This is still an issue for me on latest.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [June 13, 2017, 3:29pm UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/9 "2017-06-13T15:29:56Z")

</div>

Yeah I made [a fix to this](https://github.com/discourse/discourse/pull/4819), but using the current [PublicSuffix gem is a memory hog](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/16), so we reverted.

Long term, we want to create a optimized PublicSuffix gem to fix [this](https://meta.discourse.org/t/topic-popular-links-panel-domain-extraction-doesnt-handle-country-tlds/60156), and will also use it fix here.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 13, 2017, 7:51pm UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/10 "2017-06-13T19:51:01Z")

</div>

I do not follow, why do we need to validate every domain TLD? Just allow the text pattern…

---

<div class="post-metadata">

### Author: ![JamesNorth](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamesnorth/32/283740_2.png) [@JamesNorth](https://meta.discourse.org/u/JamesNorth)
#### Post date: [August 2, 2017, 1:11am UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/11 "2017-08-02T01:11:17Z")

</div>

Almost a year later - still the same.

Cannot add new TLDs to personal preference ‘website’ field.

Reckon a plain old text field is all it needs?

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [August 2, 2017, 7:01am UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/12 "2017-08-02T07:01:44Z")

</div>

> [@JamesNorth](#):
>
> jamesnorth.productions

I’m looking at the code right now. The regexp highlighted earlier in the topic is an easy fix.

[https://github.com/discourse/discourse/pull/5020](https://github.com/discourse/discourse/pull/5020)

> <https://github.com/begrif/discourse/blob/d471ad08c6d5c06ba244fbd0913dacb3c6c43999/app/models/user_profile.rb#L115>

It still needs to pass user website whitelist, if set. I don’t know how often that is set.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [August 2, 2017, 8:20am UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/13 "2017-08-02T08:20:24Z")

</div>

Had to fix the regexp as it was allowing “`http://https://google.com`”

[https://github.com/discourse/discourse/commit/e43799134c03d0180ef64dc941f61c26f5219314](https://github.com/discourse/discourse/commit/e43799134c03d0180ef64dc941f61c26f5219314)

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [August 2, 2017, 3:15pm UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/14 "2017-08-02T15:15:08Z")

</div>

Teach me to try to REGEXP at near midnight. 😄

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [August 2, 2017, 9:29pm UTC](https://meta.discourse.org/t/user-preference-website-does-not-allow-new-tlds/49931/15 "2017-08-02T21:29:36Z")

</div>


