Skip to content

Commit

Permalink
DNSServer: Handle examplewww.com correctly
Browse files Browse the repository at this point in the history
Just replacing 'www.' with the empty string when we assign the
domainname will remove all occurrences of 'www.', not just those
at the start of the string.

Change this to a startsWith check so that only "www." at the
beginning of the string is removed.
  • Loading branch information
SimonWilkinson committed Jan 4, 2019
1 parent 2f0f49d commit 9ab5ec5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libraries/DNSServer/src/DNSServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ void DNSServer::stop()
void DNSServer::downcaseAndRemoveWwwPrefix(String &domainName)
{
domainName.toLowerCase();
domainName.replace("www.", "");
if (domainName.startsWith("www."))
domainName.remove(0, 4);
}

void DNSServer::processNextRequest()
Expand Down

0 comments on commit 9ab5ec5

Please sign in to comment.