Skip to content

Commit bd0d23d

Browse files
pirxpilotdougwilson
authored andcommitted
perf: remove substr call from FQDN mapping
closes #1113
1 parent 1fcc562 commit bd0d23d

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ unreleased
88
- deps: parseurl@~1.3.3
99
- deps: statuses@~1.4.0
1010
* deps: parseurl@~1.3.3
11+
* perf: remove substr call from FQDN mapping
1112

1213
3.6.6 / 2018-02-14
1314
==================

index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,9 @@ function getProtohost(url) {
271271
return undefined;
272272
}
273273

274-
var searchIndex = url.indexOf('?');
275-
var pathLength = searchIndex !== -1
276-
? searchIndex
277-
: url.length;
278-
var fqdnIndex = url.substr(0, pathLength).indexOf('://');
274+
var fqdnIndex = url.indexOf('://')
279275

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

0 commit comments

Comments
 (0)