Home Forums DITA and XMetaL Discussion Spaces in the URL Reply To: Spaces in the URL


Reply to: Spaces in the URL

Thanks Derek. But I think you lost me. Both XML and HTML file names have underscores in place of spaces. The only place where spaces exist are in the TOC and topic title. Also, some of my file names do not match the title, yet it's the title that displays.

Example: c_Overview.xml is actually titled, “Welcome to Kwag Help” and displays in the address bar as, “.../webhelp_out/KwagHelp.html#Welcome%20to%20Kwag%20Help“.

I did a little noodling around and found that the .js script takes the TOC title for the url. The only place I can find spaces replaced with “%20” is in the webhelp.js (…DITA_OTdemowebhelpcustomizationcommonxmwebhelpscript). I thought I was on to something when I found this (about line 127):

            // Check for unsafe characters as per http://www.ietf.org/rfc/rfc1738.txt
            // " ", "<", ">", "#", "'", "{", "}", "|", "", "^", "~","[", "]", and "`"
            // cannot test for space using "s" as some browsers encode/decode space chars in the address bar
            // so replace any spaces with "%20"
            innerLink = innerLink.replace(/ /g, "%20");
            var unsafeHash = /[<>#'{}|\^~[]`]+/;
            var badHash = unsafeHash.test(innerLink);
            if (!badHash) {
                var frameTitle = decodeURI(innerLink);
                // Return first (if any) title that matches from ToC
                var matchFromHash = $("#whTocTree a[title = '" + frameTitle + "']:first");
                if (matchFromHash.length == 1) {
                    var hashHREF = matchFromHash.attr("href");

I deleted the “%20” in (/ /g, "%20") to no avail. I tried putting in a couple characters, too.