Skip to content

Commit 68f782c

Browse files
committed
fix issue when parameters are empty or the first arg is not an string, closes #49
1 parent 4ab20d6 commit 68f782c

File tree

3 files changed

+1455
-0
lines changed

3 files changed

+1455
-0
lines changed

lib/url-join.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
function normalize (strArray) {
88
var resultArray = [];
9+
if (strArray.length === 0) { return ''; }
10+
11+
if (typeof strArray[0] !== 'string') {
12+
throw new TypeError('Url must be a string. Received ' + strArray[0]);
13+
}
914

1015
// If the first part is a plain protocol, we combine it with the next part.
1116
if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) {

0 commit comments

Comments
 (0)