ocpsoft / rewrite

OCPsoft URL-Rewriting Framework
http://ocpsoft.org/rewrite/
Apache License 2.0
189 stars 86 forks source link

value href-attribute of base-tag not rewritten #252

Open groie opened 7 years ago

groie commented 7 years ago

Angular applications use a base-tag inside the head-tag. The base tag has an href attribute which is the intended context path of the application. This value is not rewritten causing the application not to work.

Is there a way to add another processor to ocpsoft-rewrite that it would also rewrite this attribute?

Angular documentation of base-Tag: https://angular.io/guide/router

chkal commented 7 years ago

Rewrite can only rewrite URLs, if they are passed though HttpServletResponse.encodeURL(). Typically all URLs rendered to the page are encoded this way to preserve JSESSIONID if used. So if you simple put a string literal into your page, it won't be rewritten.

You could either encode the URL using HttpServletResponse.encodeURL() yourself, or you could the Transformer API to modify the HTML by doing some kind of search + replace.