Skip to content

Commit

Permalink
feat: respect hyphens in local name generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Yagnap committed May 24, 2024
1 parent 76f0457 commit 5260e43
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/eu/snik/tag/Loader.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ public InputStream in() {

public abstract Collection<Clazz> getClasses();

/**
* Normalises the capitalisation of the given String.
* Removes all non-alphanumeric characters, so it can be used as a local name/URI.
* @param label String, presumably annotated label, from which a local name is generated
* @return String capitalised at spaces and hyphens with only alphanumeric characters (A-Za-z0-9)
*/
static String labelToLocalName(String label) {
return WordUtils.capitalizeFully(label).replaceAll("[^A-Za-z0-9]", "");
var delimiters = new char[] {' ','-'};
return WordUtils.capitalizeFully(label, delimiters).replaceAll("[^A-Za-z0-9]", "");
}
}

0 comments on commit 5260e43

Please sign in to comment.