File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,8 @@ function assert(cond, msg) {
85
85
// Combines two URLs. The baseUrl shall be absolute URL. If the url is an
86
86
// absolute URL, it will be returned as is.
87
87
function combineUrl (baseUrl , url ) {
88
+ if (!url )
89
+ return baseUrl ;
88
90
if (url .indexOf (':' ) >= 0 )
89
91
return url ;
90
92
if (url .charAt (0 ) == '/' ) {
Original file line number Diff line number Diff line change @@ -45,6 +45,22 @@ describe('util', function() {
45
45
var expected = 'http://server/test2.html' ;
46
46
expect (result ).toEqual (expected );
47
47
});
48
+
49
+ it ('returns base url when url is empty' , function () {
50
+ var baseUrl = 'http://server/index.html' ;
51
+ var url = '';
52
+ var result = combineUrl (baseUrl , url );
53
+ var expected = 'http://server/index.html' ;
54
+ expect (result ).toEqual (expected );
55
+ });
56
+
57
+ it ('returns base url when url is undefined' , function () {
58
+ var baseUrl = 'http://server/index.html' ;
59
+ var url ;
60
+ var result = combineUrl (baseUrl , url );
61
+ var expected = 'http://server/index.html' ;
62
+ expect (result ).toEqual (expected );
63
+ });
48
64
});
49
65
50
66
});
You can’t perform that action at this time.
0 commit comments