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

@@ -1,7 +1,7 @@
'use strict';
/*
Copyright 2017-2019 DigitalSailors e.K.
Copyright 2017-2021 DigitalSailors e.K.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -25,23 +25,25 @@ exports.handler = (event, context, callback) => {
request.uri += 'index.html';
callback(null, request);
} else if (prefixPath = request.uri.match('(.+)/index.html')) {
const modifiedPrefixPath = prefixPath[1].replace(/^\/+/, '/');
const response = {
status: '301',
statusDescription: 'Found',
headers: {
location: [{
key: 'Location', value: prefixPath[1] + '/',
key: 'Location', value: modifiedPrefixPath + '/',
}],
}
};
callback(null, response);
} else if (request.uri.match('/[^/.]+$')) {
const modifiedRequestURI = request.uri.replace(/^\/+/, '/');
const response = {
status: '301',
statusDescription: 'Found',
headers: {
location: [{
key: 'Location', value: request.uri + '/',
key: 'Location', value: modifiedRequestURI + '/',
}],
}
};