Skip to content

Commit

Permalink
More comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher committed May 30, 2024
1 parent ee16965 commit 6cff342
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions omod/src/main/java/org/openmrs/module/spa/SpaController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -65,6 +68,9 @@ public ResponseEntity<Resource> getStaticFileWithoutCacheHeaders(@PathVariable S
*/
@RequestMapping(value = "/**/{filename:.*\\.(?!html?)[^.]+$}")
public ResponseEntity<Resource> 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("");
Expand Down

0 comments on commit 6cff342

Please sign in to comment.