socketioMEANseed/www/node_modules/url-join/test/tests.js
www/node_modules/url-join/test/tests.jsRaw
1var urljoin = require('../lib/url-join');
2
3describe('url join', function () {
4 it('should work for simple case', function () {
5 urljoin('http://www.google.com/', 'foo/bar', '?test=123')
6 .should.eql('http://www.google.com/foo/bar?test=123');
7 });
8
9 it('should work for simple case with new syntax', function () {
10 urljoin(['http://www.google.com/', 'foo/bar', '?test=123'])
11 .should.eql('http://www.google.com/foo/bar?test=123');
12 });
13
14 it('should work for hashbang urls', function () {
15 urljoin(['http://www.google.com', '#!', 'foo/bar', '?test=123'])
16 .should.eql('http://www.google.com/#!/foo/bar?test=123');
17 });
18
19 it('should be able to join protocol', function () {
20 urljoin('http:', 'www.google.com/', 'foo/bar', '?test=123')
21 .should.eql('http://www.google.com/foo/bar?test=123');
22 });
23
24 it('should be able to join protocol with slashes', function () {
25 urljoin('http://', 'www.google.com/', 'foo/bar', '?test=123')
26 .should.eql('http://www.google.com/foo/bar?test=123');
27 });
28
29 it('should remove extra slashes', function () {
30 urljoin('http:', 'www.google.com///', 'foo/bar', '?test=123')
31 .should.eql('http://www.google.com/foo/bar?test=123');
32 });
33
34 it('should support anchors in urls', function () {
35 urljoin('http:', 'www.google.com///', 'foo/bar', '?test=123', '#faaaaa')
36 .should.eql('http://www.google.com/foo/bar?test=123#faaaaa');
37 });
38
39 it('should support protocol-relative urls', function () {
40 urljoin('//www.google.com', 'foo/bar', '?test=123')
41 .should.eql('//www.google.com/foo/bar?test=123')
42 });
43
44 it('should merge multiple query params properly', function () {
45 urljoin('http:', 'www.google.com///', 'foo/bar', '?test=123', '?key=456')
46 .should.eql('http://www.google.com/foo/bar?test=123&key=456');
47
48 urljoin('http:', 'www.google.com///', 'foo/bar', '?test=123', '?boom=value', '&key=456')
49 .should.eql('http://www.google.com/foo/bar?test=123&boom=value&key=456');
50 });
51});