Topic on Project:Support desk

Utilizing MAGICWORD PATH

6
71.67.124.174 (talkcontribs)

I have a external path as such: [file://\\network\shared folder\application file\] i would like to use string but only to insert the empty space with %20, and not replacing \ i tried [file://%5C%5Cnetwork%5Cshared%20folder%5Capplication%20file%5C] it converts all the \\ and spaces. What can i do to just convert spaces to %20?

Ciencia Al Poder (talkcontribs)

What magic word are you using and why?

206.51.148.2 (talkcontribs)

I have enable the following: https://www.mediawiki.org/wiki/Manual:$wgUrlProtocols When i link an external link through Visual Editor: [file://\\network\shared folder\application file\] , this will not work because it will get concatenated at the space because it can't recognize space but %20 instead: file://\\network\shared.

I tried using {{urlencode:string|PATH}}, but it replaces my \\ with %5C as well. I would only like the code to replace spaces with %20. Doing this [file://{{urlencode:\\network\shared folder\application file\|PATH}}]; result in : file://%5C%5Cnetwork%5Cshared%20folder%5Capplication%20file%5C And the browser does not recognize %5C

Ciencia Al Poder (talkcontribs)

Apparently, urlencode with PATH won't work, because it encodes "/" characters, which from my understanding it shouldn't.

You should use forward slashes in URLs, and it should end with 5 forward slashes at the start: file://///network/shared%20folder/application%20file.

Try to not use spaces in URLs, or use URLENCODE on every segment of the URL, not on the whole URL.

AmazingTrans (talkcontribs)

Thank you for your comment Ciencia. Unfortunately, a lot of our folders has spaces and i cant change all the folders naming convention because other people has links to them as well, and i know if we work on website design, we utilize <a href>, it works on web browsers. Just wondering if i have to insert %20 myself or maybe there is some extension that covers something like this. Thanks

Ciencia Al Poder (talkcontribs)

wiki syntax break external links on spaces, so you must encode them with %20.

What I mean about URLENCODE::

file://///network/{{urlencode:shared folder|PATH}}/{{urlencode:application file|PATH}}

produces:

file://///network/shared%20folder/application%20file

That's tedious, yes. Maybe you can simply enable Extension:StringFunctions (which is integrated in Extension:ParserFunctions but a flag needs to be set) and do a replace of spaces -> %20, and make a template with it to use for your links.

Reply to "Utilizing MAGICWORD PATH"