From 5260e437449eeb2d5ada4eb6cfbae7c81f76fa75 Mon Sep 17 00:00:00 2001 From: "Hannes R. Brunsch" Date: Fri, 24 May 2024 13:39:17 +0200 Subject: [PATCH] feat: respect hyphens in local name generation --- src/main/java/eu/snik/tag/Loader.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/snik/tag/Loader.java b/src/main/java/eu/snik/tag/Loader.java index 5218a3cc..1d6694de 100644 --- a/src/main/java/eu/snik/tag/Loader.java +++ b/src/main/java/eu/snik/tag/Loader.java @@ -22,7 +22,14 @@ public InputStream in() { public abstract Collection 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]", ""); } }