Skip to content

Commit 7c5a128

Browse files
soulman-is-goodrbren
authored andcommitted
Added port option to parseUrl, test with parseUrl (rbren#33)
1 parent 4d8c399 commit 7c5a128

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ Parser.parseURL = function(feedUrl, options, callback) {
270270
auth: parsedUrl.auth,
271271
protocol: parsedUrl.protocol,
272272
hostname: parsedUrl.hostname,
273+
port: parsedUrl.port,
273274
path: parsedUrl.path,
274275
headers: {'User-Agent': 'rss-parser'}
275276
}, function(res) {

test/parser.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22

33
var FS = require('fs');
4+
var HTTP = require('http');
45

56
var Parser = require('../index.js');
67

@@ -97,4 +98,25 @@ describe('Parser', function() {
9798
done();
9899
});
99100
});
101+
102+
it('should parse URL', function(done) {
103+
var server = HTTP.createServer(function(req, res) {
104+
var file = FS.createReadStream(INPUT_FILE, 'utf8');
105+
106+
file.pipe(res);
107+
});
108+
server.listen(function() {
109+
var port = server.address().port;
110+
var url = 'http://localhost:' + port;
111+
112+
Parser.parseURL(url, function(err, parsed) {
113+
Expect(err).to.equal(null);
114+
var str = JSON.stringify(parsed, null, 2);
115+
var expected = FS.readFileSync(OUTPUT_FILE, 'utf8');
116+
Expect(str).to.equal(expected);
117+
done();
118+
});
119+
});
120+
121+
});
100122
})

0 commit comments

Comments
 (0)