Commit 2252ac92 authored by Jan Potoms's avatar Jan Potoms

Merge pull request #1 from nw/master

fixes line parse to support values with ':' like full sitemap urls.
parents 2450a75e 1c91872e
......@@ -14,14 +14,12 @@ var START_GROUP = 'START_GROUP',
function parseLine(line) {
var commentFree = line.replace(/#.*$/, ''),
parts = commentFree.split(':');
if (parts.length !== 2) {
return null;
}
index = commentFree.indexOf(':');
if(index === -1) return null;
var field = parts[0].trim().toLowerCase(),
value = parts[1].trim();
var field = commentFree.substr(0,index).trim().toLowerCase(),
value = commentFree.substr(index+1).trim();
switch (field) {
case 'user-agent':
......
user-agent: *
disallow: /
sitemap: /sitemap.xml
\ No newline at end of file
sitemap: /sitemap.xml
sitemap: http://example.com/alt_sitemap.xml
......@@ -75,6 +75,8 @@ describe('parser', function () {
.then(function (parsed) {
assert.deepPropertyVal(parsed, 'extensions[0].extension', 'sitemap');
assert.deepPropertyVal(parsed, 'extensions[0].value', '/sitemap.xml');
assert.deepPropertyVal(parsed, 'extensions[1].extension', 'sitemap');
assert.deepPropertyVal(parsed, 'extensions[1].value', 'http://example.com/alt_sitemap.xml');
done();
})
.catch(done);
......@@ -103,4 +105,4 @@ describe('parser', function () {
.catch(done);
});
});
\ No newline at end of file
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment