-
New Feature
-
Resolution: Won't Do
-
Normal
-
None
-
9.6.0
-
Security Level: Jimmy
-
None
User Story
As an developer, I must resolve relative urls used in my ZK application while embedded so that I can serve the relevant resources (scripts, files, urls, etc)
Currently, there is no easy way to rewrite the urls received from server-side
Acceptance Criteria
Either have relative URLs for scripts, stylesheets, images, files, resources, etc automatically rewritten when the zEmbedded library is available in the page, or have an easy to use API on the zEmbedded object which accepts a relative url and rewrite it to match the current zEmbedded context for easy overrides to existing widgets. ideally both.
Details
Current override method require blind-fetch of resource URLs and using string operations:
function retrieveZkUrlContext(){ if(!zEmbedded || !zEmbedded._zk_loadedResource){ return; } var resource = Object.keys(zEmbedded._zk_loadedResource)[0]; return resource.split("zkau")[0]; } zk.afterLoad("zk", function () { var _xcmd0 = {}; zk.override(zAu.cmd0, _xcmd0, { download: function(url) { var newUrl = null; if( retrieveZkUrlContext()){ newUrl = retrieveZkUrlContext() + "zkau" + url.split("zkau")[1]; } else{ newUrl = url; } var result = _xcmd0.download.apply(this, [newUrl]); return result; } }); });