Skip to content

Commit

Permalink
fix: base url validation
Browse files Browse the repository at this point in the history
  • Loading branch information
yevheniyJ committed Jun 3, 2024
1 parent 1510a1a commit a01c697
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class CrowdinPropertiesLoader {
private static final String PROPERTY_FILES_UPDATE_STRINGS = "update_strings";
private static final String PROPERTY_EXCLUDED_TARGET_LANGUAGES = "excluded_target_languages";

private static final Pattern BASE_URL_PATTERN = Pattern.compile("^(https://([a-zA-Z0-9_-]+\\.)?crowdin\\.com/?|http://(.+)\\.dev\\.crowdin\\.com/?)$");
private static final Pattern BASE_URL_PATTERN = Pattern.compile("^(https://([a-zA-Z0-9_-]+\\.(api\\.)?)?crowdin\\.com/?|http://(.+)\\.dev\\.crowdin\\.com/?)$");

public static boolean isWorkspaceNotPrepared(Project project) {
return CrowdinFileProvider.getCrowdinConfigFile(project) == null;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/messages/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ errors.config.invalid_format=Property '%s' has wrong format
errors.config.has_errors=Errors in the configuration file:
errors.config.missing_config_file=File <b>'%s'</b> with Crowdin plugin configuration doesn't exist in the project root directory
errors.config.missing_property=Required property <b>'%s'</b> is missing in the configuration file
errors.config.invalid_url_property=Base URL contains <b>'%s'</b> unexpected value. The expected format is 'https://crowdin.com' or 'https://{domain_name}.crowdin.com'
errors.config.invalid_url_property=Base URL contains <b>'%s'</b> unexpected value. The expected format is 'https://crowdin.com', 'https://{domain_name}.api.crowdin.com' or 'https://{domain_name}.crowdin.com'
errors.config.invalid_url_env=Environment variable <b>'%s'</b> contains unexpected <b>'%s'</b> value. The expected format is 'https://crowdin.com' or 'https://{domain_name}.crowdin.com'

errors.extract_file=Failed to extract the file '%s'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void isBaseUrlValidTest() {
Assertions.assertTrue(isBaseUrlValid("http://test.dev.crowdin.com"));
Assertions.assertTrue(isBaseUrlValid("http://my-organization.test.dev.crowdin.com"));
Assertions.assertTrue(isBaseUrlValid("https://ti-it.crowdin.com"));
Assertions.assertTrue(isBaseUrlValid("https://ti-it.api.crowdin.com"));
Assertions.assertFalse(isBaseUrlValid("http://my-organization.testdev.crowdin.com"));
Assertions.assertFalse(isBaseUrlValid("http://crowdin.com"));
Assertions.assertFalse(isBaseUrlValid("http://myorganization.crowdin.com"));
Expand Down

0 comments on commit a01c697

Please sign in to comment.