Skip to content
Permalink
Browse files

perf: remove substr call from FQDN mapping

closes #1113
  • Loading branch information...
pirxpilot authored and dougwilson committed Mar 25, 2019
1 parent 1fcc562 commit bd0d23dad5754c540770c3f1af6ef2d76f54718a
Showing with 3 additions and 6 deletions.
  1. +1 −0 HISTORY.md
  2. +2 −6 index.js
@@ -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
==================
@@ -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.
You can’t perform that action at this time.