Skip to content

Commit

Permalink
simplify code - recent sling implementations can handle url params an…
Browse files Browse the repository at this point in the history
…d fragment parts in paths properly
  • Loading branch information
stefanseifert committed Jul 17, 2024
1 parent cffb396 commit 50b27cd
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions core/src/main/java/io/wcm/testing/mock/aem/MockExternalizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,25 +179,7 @@ private static String getMappedPath(@Nullable ResourceResolver resourceResolver,
if (resourceResolver == null) {
return path;
}

// separate URL parameters/fragment from path
String suffixlessPath = path;
String suffix = "";
int urlParamPos = path.indexOf('?');
if (urlParamPos >= 0) {
suffixlessPath = path.substring(0, urlParamPos);
suffix = path.substring(urlParamPos);
}
else {
int fragmentPos = path.indexOf('#');
if (fragmentPos >= 0) {
suffixlessPath = path.substring(0, fragmentPos);
suffix = path.substring(fragmentPos);
}
}

// rewrite path and re-append suffix
return resourceResolver.map(suffixlessPath) + suffix;
return resourceResolver.map(path);
}

}

0 comments on commit 50b27cd

Please sign in to comment.