From 6cff342f52fc31a72197c2ff61f1dcad44183ae6 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 30 May 2024 15:47:46 -0400 Subject: [PATCH] More comments --- .../src/main/java/org/openmrs/module/spa/SpaController.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/omod/src/main/java/org/openmrs/module/spa/SpaController.java b/omod/src/main/java/org/openmrs/module/spa/SpaController.java index f41febd..2f97a91 100644 --- a/omod/src/main/java/org/openmrs/module/spa/SpaController.java +++ b/omod/src/main/java/org/openmrs/module/spa/SpaController.java @@ -26,6 +26,9 @@ @Slf4j public class SpaController { + /** + * Since we support both /spa and /ws/spa as the URL, we use this pattern to remove it from the request URI. + */ private static final Pattern URL_PATTERN = Pattern.compile("(?:/ws)?/spa"); private final SpaResourceLoader resourceLoader; @@ -65,6 +68,9 @@ public ResponseEntity getStaticFileWithoutCacheHeaders(@PathVariable S */ @RequestMapping(value = "/**/{filename:.*\\.(?!html?)[^.]+$}") public ResponseEntity getStaticFile(HttpServletRequest request) { + // although the filename is there as a path variable, it's really being used as a regex. We also need the + // directory relative to the /spa or /ws/spa URL to locate the file, so we extract that from the incoming + // request String filename = request.getRequestURI(); filename = filename.substring(request.getContextPath().length()); filename = URL_PATTERN.matcher(filename).replaceFirst("");