mirror of
				https://github.com/eledio-cloud/standard-redirects-for-cloudfront.git
				synced 2025-10-31 00:12:56 +01:00 
			
		
		
		
	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:
		
							
								
								
									
										8
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								index.js
									
									
									
									
									
								
							| @@ -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 + '/', | ||||
|         }], | ||||
|       } | ||||
|     }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user