Skip to content

Commit

Permalink
Handling Unicode in Project Generation stripAccents
Browse files Browse the repository at this point in the history
Fix for Bug : spring-io#1328
  • Loading branch information
nirbhay24 committed Nov 20, 2022
1 parent 6b84396 commit ec4bdbe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void setDependencies(List<String> dependencies) {
}

public String getName() {
return this.name;
return cleanInputValue(this.name);
}

public void setName(String name) {
Expand All @@ -90,15 +90,15 @@ public void setDescription(String description) {
}

public String getGroupId() {
return this.groupId;
return cleanInputValue(this.groupId);
}

public void setGroupId(String groupId) {
this.groupId = groupId;
}

public String getArtifactId() {
return this.artifactId;
return cleanInputValue(this.artifactId);
}

public void setArtifactId(String artifactId) {
Expand Down Expand Up @@ -147,7 +147,7 @@ public void setLanguage(String language) {

public String getPackageName() {
if (StringUtils.hasText(this.packageName)) {
return this.packageName;
return cleanInputValue(this.packageName);
}
if (StringUtils.hasText(this.groupId) && StringUtils.hasText(this.artifactId)) {
return getGroupId() + "." + getArtifactId();
Expand Down Expand Up @@ -175,4 +175,11 @@ public void setBaseDir(String baseDir) {
this.baseDir = baseDir;
}

private String cleanInputValue(String inputString) {
if (StringUtils.hasText(inputString)) {
return org.apache.commons.lang3.StringUtils.stripAccents(inputString);
}
return inputString;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ void baseDirectorySeparatedBySpace() {
assertDefaultProject(project.resolveModule("demo trial"));
}

@Test
void projectNameWithAccentRemoved() {
ProjectStructure project = downloadZip("/starter.zip?artifactId=demo&baseDir=demo trial&name=Demö");
assertDefaultProject(project.resolveModule("demo trial"));
}

}

0 comments on commit ec4bdbe

Please sign in to comment.