Skip to content

Commit

Permalink
perf: remove substr call from FQDN mapping
Browse files Browse the repository at this point in the history
closes #1113
  • Loading branch information
pirxpilot authored and dougwilson committed May 17, 2019
1 parent 1fcc562 commit bd0d23d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Expand Up @@ -8,6 +8,7 @@ unreleased
- deps: parseurl@~1.3.3
- deps: statuses@~1.4.0
* deps: parseurl@~1.3.3
* perf: remove substr call from FQDN mapping

3.6.6 / 2018-02-14
==================
Expand Down
8 changes: 2 additions & 6 deletions index.js
Expand Up @@ -271,13 +271,9 @@ function getProtohost(url) {
return undefined;
}

var searchIndex = url.indexOf('?');
var pathLength = searchIndex !== -1
? searchIndex
: url.length;
var fqdnIndex = url.substr(0, pathLength).indexOf('://');
var fqdnIndex = url.indexOf('://')

return fqdnIndex !== -1
return fqdnIndex !== -1 && url.lastIndexOf('?', fqdnIndex) === -1
? url.substr(0, url.indexOf('/', 3 + fqdnIndex))
: undefined;
}

0 comments on commit bd0d23d

Please sign in to comment.