Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace ci prefix only at rewriting part #1681

Merged
merged 4 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions deployment/lambdas/cf-url-rewriter/cf-url-rewriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { httpsGet } from './https-get';

export async function handler(event: CloudFrontRequestEvent, context: Context, callback: CloudFrontRequestCallback) {
const request = event.Records[0].cf.request;
// Incoming URLs from ci.opensearch.org will have a '/ci/123/' prefix, remove the prefix path from requests into S3.
request.uri = request.uri.replace(/^\/ci\/...\//, '\/');

if (request.uri.includes("/latest/")) {

Expand All @@ -24,6 +22,8 @@ export async function handler(event: CloudFrontRequestEvent, context: Context, c
}

} else {
// Incoming URLs from ci.opensearch.org will have a '/ci/123/' prefix, remove the prefix path from requests into S3.
request.uri = request.uri.replace(/^\/ci\/...\//, '\/');
callback(null, request);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ test('handler with latest url and with ci keyword and valid latest field', async

await handler(event, context, callback);

expect(httpsGet).toBeCalledWith('https://test.cloudfront.net/bundle-build-dashboards/1.2.0/index.json');
expect(httpsGet).toBeCalledWith('https://test.cloudfront.net/ci/dbc/bundle-build-dashboards/1.2.0/index.json');

expect(callback).toHaveBeenCalledWith(
null,
{
"headers": {
"cache-control": [{ "key": "Cache-Control", "value": "max-age=3600" }],
"location": [{ "key": "Location", "value": "/bundle-build-dashboards/1.2.0/123/linux/x64/" }]
"location": [{ "key": "Location", "value": "/ci/dbc/bundle-build-dashboards/1.2.0/123/linux/x64/" }]
},
"status": "302",
"statusDescription": "Moved temporarily"
Expand Down