From 0e81068409098a656470d50bc43b83d79be1fe9f Mon Sep 17 00:00:00 2001 From: Matt Creaser Date: Fri, 15 Nov 2024 13:26:58 -0400 Subject: [PATCH] fix(api): Fix connecting to AppSync from China with API category (#2948) --- .../java/com/amplifyframework/api/aws/DomainType.java | 2 +- .../com/amplifyframework/api/aws/DomainTypeTest.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/aws-api/src/main/java/com/amplifyframework/api/aws/DomainType.java b/aws-api/src/main/java/com/amplifyframework/api/aws/DomainType.java index ce5d3c27c1..8b276d42e9 100644 --- a/aws-api/src/main/java/com/amplifyframework/api/aws/DomainType.java +++ b/aws-api/src/main/java/com/amplifyframework/api/aws/DomainType.java @@ -34,7 +34,7 @@ public enum DomainType { CUSTOM; private static final String STANDARD_ENDPOINT_REGEX = - "^https:\\/\\/\\w{26}\\.appsync\\-api\\.\\w{2}(?:(?:\\-\\w{2,})+)\\-\\d\\.amazonaws.com\\/graphql$"; + "^https:\\/\\/\\w{26}\\.appsync\\-api\\.\\w{2}(?:\\-\\w{2,})+\\-\\d\\.amazonaws.com(?:\\.cn)?\\/graphql$"; /** * Get Domain type based on defined endpoint. diff --git a/aws-api/src/test/java/com/amplifyframework/api/aws/DomainTypeTest.java b/aws-api/src/test/java/com/amplifyframework/api/aws/DomainTypeTest.java index da0358c8ea..a970b77126 100644 --- a/aws-api/src/test/java/com/amplifyframework/api/aws/DomainTypeTest.java +++ b/aws-api/src/test/java/com/amplifyframework/api/aws/DomainTypeTest.java @@ -24,6 +24,8 @@ public class DomainTypeTest { private static final String STANDARD_URL = "https://abcdefghijklmnopqrstuvwxyz.appsync-api.us-west-2.amazonaws.com/graphql"; + private static final String STANDARD_URL_CHINA = + "https://abcdefghijklmnopqrstuvwxyz.appsync-api.us-west-2.amazonaws.com.cn/graphql"; private static final String CUSTOM_URL = "https://something.in.somedomain.com/graphql"; /** @@ -34,6 +36,14 @@ public void testStandardURLMatch() { Assert.assertEquals(STANDARD, DomainType.from(STANDARD_URL)); } + /** + * Test that Domain type is {@link DomainType#STANDARD} for generated URL. + */ + @Test + public void testStandardURLChinaMatch() { + Assert.assertEquals(STANDARD, DomainType.from(STANDARD_URL_CHINA)); + } + /** * Test that Domain type is set to {@link DomainType#CUSTOM} for custom URLs. */