fix #10058 wrong domain name shown when connecting .eth
add a check on the function that adds the stateofus domain to usernames. if the username already contains a domain, don't concat stateofus domain to it Signed-off-by: yenda <eric@status.im>
This commit is contained in:
parent
e11385e350
commit
a5a00e0a2c
|
@ -4,9 +4,22 @@
|
||||||
|
|
||||||
(def domain "stateofus.eth")
|
(def domain "stateofus.eth")
|
||||||
|
|
||||||
(defn subdomain [username]
|
(defn subdomain
|
||||||
|
[username]
|
||||||
(str username "." domain))
|
(str username "." domain))
|
||||||
|
|
||||||
|
(defn username-with-domain
|
||||||
|
"checks if the username is a status username or a ens name
|
||||||
|
for that we check if there is a dot in the username, which
|
||||||
|
would indicate that there is already a domain name so we don't
|
||||||
|
concatenated stateofus domain to it"
|
||||||
|
[username]
|
||||||
|
(when (and (string? username)
|
||||||
|
(seq username))
|
||||||
|
(if (string/includes? username ".")
|
||||||
|
username
|
||||||
|
(subdomain username))))
|
||||||
|
|
||||||
(defn username [name]
|
(defn username [name]
|
||||||
(when (and name (string/ends-with? name domain))
|
(when (and name (string/ends-with? name domain))
|
||||||
(first (string/split name "."))))
|
(first (string/split name "."))))
|
||||||
|
|
|
@ -361,10 +361,10 @@
|
||||||
(case state
|
(case state
|
||||||
:available
|
:available
|
||||||
(i18n/label :t/ens-username-registration-confirmation
|
(i18n/label :t/ens-username-registration-confirmation
|
||||||
{:username (stateofus/subdomain username)})
|
{:username (stateofus/username-with-domain username)})
|
||||||
:connected-with-different-key
|
:connected-with-different-key
|
||||||
(i18n/label :t/ens-username-connection-confirmation
|
(i18n/label :t/ens-username-connection-confirmation
|
||||||
{:username (stateofus/subdomain username)})
|
{:username (stateofus/username-with-domain username)})
|
||||||
:connected
|
:connected
|
||||||
(i18n/label :t/ens-saved-title)
|
(i18n/label :t/ens-saved-title)
|
||||||
;;NOTE: this state can't be reached atm
|
;;NOTE: this state can't be reached atm
|
||||||
|
@ -384,7 +384,7 @@
|
||||||
:connected
|
:connected
|
||||||
[react/nested-text
|
[react/nested-text
|
||||||
{:style {:font-size 15 :text-align :center}}
|
{:style {:font-size 15 :text-align :center}}
|
||||||
(stateofus/subdomain username)
|
(stateofus/username-with-domain username)
|
||||||
[{:style {:color colors/gray}}
|
[{:style {:color colors/gray}}
|
||||||
(i18n/label :t/ens-saved)]]
|
(i18n/label :t/ens-saved)]]
|
||||||
;;NOTE: this state can't be reached atm
|
;;NOTE: this state can't be reached atm
|
||||||
|
|
|
@ -7,3 +7,9 @@
|
||||||
(is (true? (stateofus/valid-username? "andrey")))
|
(is (true? (stateofus/valid-username? "andrey")))
|
||||||
(is (false? (stateofus/valid-username? "Andrey")))
|
(is (false? (stateofus/valid-username? "Andrey")))
|
||||||
(is (true? (stateofus/valid-username? "andrey12"))))
|
(is (true? (stateofus/valid-username? "andrey12"))))
|
||||||
|
|
||||||
|
(deftest username-with-domain
|
||||||
|
(is (nil? (stateofus/username-with-domain nil)))
|
||||||
|
(is (= "andrey.stateofus.eth" (stateofus/username-with-domain "andrey")))
|
||||||
|
(is (= "andrey.eth" (stateofus/username-with-domain "andrey.eth")))
|
||||||
|
(is (= "andrey.stateofus.eth" (stateofus/username-with-domain "andrey.stateofus.eth"))))
|
||||||
|
|
Loading…
Reference in New Issue