fixed a problem with network-path references (see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2), updated mocha

This commit is contained in:
Oliver Gutperl
2021-05-30 12:01:53 +02:00
parent 558ab482d9
commit 6271dd98c0
4 changed files with 1846 additions and 9 deletions

View File

@@ -56,7 +56,7 @@ describe('Testing index.js', function() {
done(assert.strictEqual(data.uri, '/foo/bar/index.html'));
});
});
it('/foo -> external redirect (301) -> /foo/', function(done) {
const event = {
Records:[{ cf: {
@@ -65,7 +65,7 @@ describe('Testing index.js', function() {
}
} }] };
index.handler(event, {}, (err, data) => {
done(assert.strictEqual(data.status, '301')
done(assert.strictEqual(data.status, '301')
|| assert.strictEqual(data.headers.location[0].key, 'Location')
|| assert.strictEqual(data.headers.location[0].value, '/foo/'));
});
@@ -101,9 +101,38 @@ describe('Testing index.js', function() {
}
} }] };
index.handler(event, {}, (err, data) => {
done(assert.strictEqual(data.status, '301')
done(assert.strictEqual(data.status, '301')
|| assert.strictEqual(data.headers.location[0].key, 'Location')
|| assert.strictEqual(data.headers.location[0].value, '/foo/'));
});
});
it('//foo/index.html -> external redirect (301) -> /foo/', function(done) {
const event = {
Records:[{ cf: {
request: {
uri: '//foo/index.html'
}
} }] };
index.handler(event, {}, (err, data) => {
done(assert.strictEqual(data.status, '301')
|| assert.strictEqual(data.headers.location[0].key, 'Location')
|| assert.strictEqual(data.headers.location[0].value, '/foo/'));
});
});
it('///foo -> external redirect (301) -> /foo/', function(done) {
const event = {
Records:[{ cf: {
request: {
uri: '//foo/index.html'
}
} }] };
index.handler(event, {}, (err, data) => {
done(assert.strictEqual(data.status, '301')
|| assert.strictEqual(data.headers.location[0].key, 'Location')
|| assert.strictEqual(data.headers.location[0].value, '/foo/'));
});
});
});