@@ -284,6 +284,23 @@ public boolean isTemplateMatchWithinText(String text) throws SpdxCompareExceptio
284284 }
285285 }
286286
287+ /**
288+ * Normalizes text for use in the template matcher
289+ * @param text text to normalize
290+ * @return text that is normalized for license comparison
291+ */
292+ public String normalizeText (String text ) {
293+ StringBuilder normalizedText = new StringBuilder ();
294+
295+ for (String token :LicenseTextHelper .tokenizeLicenseText (LicenseTextHelper .removeLineSeparators (
296+ LicenseCompareHelper .removeCommentChars (text )), new HashMap <>())) {
297+ normalizedText .append (
298+ LicenseTextHelper .NORMALIZE_TOKENS .getOrDefault (token .toLowerCase (), token .toLowerCase ()));
299+ normalizedText .append (' ' );
300+ }
301+ return normalizedText .toString ();
302+ }
303+
287304 /**
288305 * @param text text to search for
289306 * @return the text matching the beginning and end regular expressions for the template. Null if there is no match.
@@ -298,17 +315,8 @@ public boolean isTemplateMatchWithinText(String text) throws SpdxCompareExceptio
298315 if (text == null || text .isEmpty () || template == null ) {
299316 return null ;
300317 }
301-
302- StringBuilder normalizedText = new StringBuilder ();
303-
304- for (String token :LicenseTextHelper .tokenizeLicenseText (LicenseTextHelper .removeLineSeparators (
305- LicenseCompareHelper .removeCommentChars (text )), new HashMap <>())) {
306- normalizedText .append (
307- LicenseTextHelper .NORMALIZE_TOKENS .getOrDefault (token .toLowerCase (), token .toLowerCase ()));
308- normalizedText .append (' ' );
309- }
310-
311- String compareText = normalizedText .toString ();
318+
319+ String compareText = normalizeText (text );
312320
313321 Pattern quickPattern = Pattern .compile (getQuickMatchRegex (WORD_LIMIT ));
314322 if (quickPattern .matcher (compareText ).find ()) {
0 commit comments