-
Notifications
You must be signed in to change notification settings - Fork 3
/
redirect-lambda.js
36 lines (29 loc) · 1.05 KB
/
redirect-lambda.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function handler(event) {
var request = event.request;
var uri = `${request.uri}`;
uri=uri.replace("/docs/", "/industrial-iot-open-source/")
uri=uri.replace("CODE_OF_CONDUCT", "index");
uri=uri.replace("CONTRIBUTING", "index");
uri=uri.replace("CHANGELOG", "index");
uri=uri.replace("docker-images", "index");
console.log (uri);
if(uri.startsWith("/")) {
uri=`https://developer.siemens.com${uri}`;
} else {
uri="https://developer.siemens.com/industrial-iot-open-source/index.html";
}
if (uri==="https://developer.siemens.com/") {
uri="https://developer.siemens.com/industrial-iot-open-source/index.html";
}
// match any .md at the end of URI and replace with .html
uri=uri.replace(/\.md$/, '\.html');
var response = {
statusCode: 302,
statusDescription: 'Found',
headers: {
'cloudfront-functions': { value: 'generated-by-CloudFront-Functions' },
'location': { value: uri}
}
};
return response;
}