tests, fix for #4647. Proper escaping project name per npmjs (#4648)

This commit is contained in:
Tony Tam
2017-01-25 01:08:54 -08:00
committed by wing328
parent 78f38f1a1f
commit ecaa8b1ede
3 changed files with 34 additions and 4 deletions

View File

@@ -310,7 +310,12 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
if (info.getTitle() != null) {
// when info.title is defined, use it for projectName
// used in package.json
projectName = dashize(info.getTitle());
projectName = info.getTitle()
.replaceAll("[^a-zA-Z0-9]", "-")
.replaceAll("^[-]*", "")
.replaceAll("[-]*$", "")
.replaceAll("[-]{2,}", "-")
.toLowerCase();
this.additionalProperties.put("projectName", projectName);
}
}