Same scenario as 09/07/2009 post "Broken URL under Edit button" except running 8.5.1 server and needed to slightly change the workaround in that post.
For Edit button:
Used same code for workaround, except with slight modification…
used:
var url=@LeftBack(context.getUrl().toString(),"/")
instead of:
var url=@LeftBack(context.getUrl().toString(),"/")+facesContext.getExternalContext().getRequestContextPath();
Same issue applies to URLs of inline images:
Applied similar workaround to xpWikiStyle Script Library
url=@LeftBack(context.getUrl().toString(),"/");