Skip to content

Commit 87f4cc1

Browse files
authored
fix sample on Safari (#16)
1 parent 650f4bc commit 87f4cc1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

bin/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,4 @@ awslocal lambda list-function-url-configs --function-name presign | jq -r '.Func
9595
echo "Fetching function URL for 'list' Lambda..."
9696
awslocal lambda list-function-url-configs --function-name list | jq -r '.FunctionUrlConfigs[0].FunctionUrl'
9797

98-
echo "Now open the Web app under https://webapp.s3.localhost.localstack.cloud/index.html and paste the function URLs above (make sure to use https:// as protocol)"
98+
echo "Now open the Web app under https://webapp.s3-website.localhost.localstack.cloud and paste the function URLs above (make sure to use https:// as protocol)"

website/app.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@
1919
event.returnValue = false;
2020

2121
event.preventDefault();
22-
2322
let action = $(this).find("button[type=submit]:focus").attr('name');
23+
if (action === undefined) {
24+
// the jquery find with the focus does not work on Safari, maybe because the focus is not instantly given
25+
// fallback to manually retrieving the submitter from the original event
26+
action = event.originalEvent.submitter.getAttribute('name')
27+
}
2428

2529
if (action == "load") {
2630
let baseUrl = `${document.location.protocol}//${document.location.host}`;
2731
if (baseUrl.indexOf("file://") >= 0) {
2832
baseUrl = `http://localhost:4566`;
2933
}
30-
baseUrl = baseUrl.replace("://webapp.s3.", "://");
34+
baseUrl = baseUrl.replace("://webapp.s3.", "://").replace("://webapp.s3-website.", "://");
3135
const headers = {authorization: "AWS4-HMAC-SHA256 Credential=test/20231004/us-east-1/lambda/aws4_request, ..."};
3236
const loadUrl = async (funcName, resultElement) => {
3337
const url = `${baseUrl}/2021-10-31/functions/${funcName}/urls`;

0 commit comments

Comments
 (0)