mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
Remove www. from website name
This commit is contained in:
parent
9d34289d08
commit
2cbd87c08c
2 changed files with 18 additions and 4 deletions
|
@ -146,7 +146,7 @@ class UserSerializer < BasicUserSerializer
|
||||||
def website_name
|
def website_name
|
||||||
uri = URI(website.to_s) rescue nil
|
uri = URI(website.to_s) rescue nil
|
||||||
return if uri.nil? || uri.host.nil?
|
return if uri.nil? || uri.host.nil?
|
||||||
uri.host + uri.path
|
uri.host.sub(/^www\./,'') + uri.path
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_website_name
|
def include_website_name
|
||||||
|
|
|
@ -104,15 +104,29 @@ describe UserSerializer do
|
||||||
|
|
||||||
context "when website has a subdomain" do
|
context "when website has a subdomain" do
|
||||||
before do
|
before do
|
||||||
user.user_profile.website = 'http://www.example.com/user'
|
user.user_profile.website = 'http://subdomain.example.com/user'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has a website with a subdomain" do
|
it "has a website with a subdomain" do
|
||||||
expect(json[:website]).to eq 'http://www.example.com/user'
|
expect(json[:website]).to eq 'http://subdomain.example.com/user'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns website name with the subdomain" do
|
it "returns website name with the subdomain" do
|
||||||
expect(json[:website_name]).to eq 'www.example.com/user'
|
expect(json[:website_name]).to eq 'subdomain.example.com/user'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when website has www" do
|
||||||
|
before do
|
||||||
|
user.user_profile.website = 'http://www.example.com/user'
|
||||||
|
end
|
||||||
|
|
||||||
|
it "has a website with the www" do
|
||||||
|
expect(json[:website]).to eq 'http://www.example.com/user'
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns website name without the www" do
|
||||||
|
expect(json[:website_name]).to eq 'example.com/user'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue