Skip to content

Commit

Permalink
fix: bundles urls
Browse files Browse the repository at this point in the history
  • Loading branch information
yevheniyJ committed Nov 1, 2024
1 parent de6c089 commit b0c77e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import static com.crowdin.Constants.*;
import static com.crowdin.util.Util.extractOrganization;
import static com.crowdin.util.Util.isEnterpriseUrl;

public class DownloadWindow implements ContentTab {

Expand Down Expand Up @@ -184,15 +185,15 @@ public String buildBundleUrl() {
var bundle = this.getSelectedBundle();

if (bundle == null) {
if (this.baseUrl != null) {
if (this.baseUrl != null && isEnterpriseUrl(this.baseUrl)) {
String organization = extractOrganization(this.baseUrl);
return "https://" + organization + ".crowdin.com/u/projects/" + project.getId() + "/download";
} else {
return "https://crowdin.com/project/" + project.getIdentifier() + "/download#bundles";
}
}

if (this.baseUrl != null) {
if (this.baseUrl != null && isEnterpriseUrl(this.baseUrl)) {
String organization = extractOrganization(this.baseUrl);
return "https://" + organization + ".crowdin.com/u/projects/" + project.getId() + "/translations/bundle/" + bundle.getId();
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/crowdin/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ public static String extractOrganization(String baseUrl) {
}
return baseUrl.split(".crowdin.com")[0].split("https://")[1];
}

public static boolean isEnterpriseUrl(String baseUrl) {
return !baseUrl.contains("https://api.crowdin.com");
}
}
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}.api.crowdin.com'
errors.config.invalid_url_property=Base URL contains <b>'%s'</b> unexpected value. The expected format is 'https://api.crowdin.com' or 'https://{domain_name}.api.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

0 comments on commit b0c77e3

Please sign in to comment.