UNPKG

954 BJavaScriptView Raw
1// Generated by CoffeeScript 1.11.1
2(function() {
3 var url;
4
5 url = require('url');
6
7 module.exports = function(u) {
8 var _, index, p, pass, query, ref, ref1, ref2, s, server, type, user;
9 p = url.parse(u);
10 s = [];
11 s.push(p.protocol);
12 s.push('//');
13 if (p.auth) {
14 ref = p.auth.split(':'), user = ref[0], pass = ref[1];
15 s.push(encodeURIComponent(user));
16 if (pass) {
17 s.push(':');
18 s.push(encodeURIComponent(pass));
19 }
20 s.push('@');
21 }
22 s.push(p.hostname);
23 if (p.port) {
24 s.push(':');
25 s.push(p.port);
26 }
27 server = s.join('');
28 ref2 = ((ref1 = p.pathname) != null ? ref1 : '').split('/'), _ = ref2[0], index = ref2[1], type = ref2[2];
29 query = p.query;
30 return {
31 server: server,
32 index: index ? index : null,
33 type: type ? type : null,
34 query: query != null ? query : ''
35 };
36 };
37
38}).call(this);
39
40//# sourceMappingURL=parse.js.map