Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Thayts/1
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} function p.test(frame) local url = frame.args[1] local count = 0 local urlEnc = {} local delim = "" for part in mw.text.gsplit(url, "[;/?:@&=+$,#]") do urlEnc[#urlEnc + 1] = delim urlEnc[#urlEnc + 1] = mw.uri.encode(mw.uri.decode(part, "PATH"), "PATH") count = count + #part + 1 delim = url:sub(count, count) end return table.concat(urlEnc) end local function split(str, del, from) local i, j from = from or 1 i, j = str:find(del, from) if i and j then return str:sub(1, i - 1), str:sub(j + 1), i, j end return str end function p.test2(frame) local i, j, urlSplit, urlPath local url = frame.args[1] local urlPre = "" i, j = url:find("//", 1, true) if i == 1 or (i and i > 1 and url:sub(i - 1, i - 1) == ':') then urlSplit = {split(url, "[/?#]", j + 1)} urlPre = urlSplit[1] if urlSplit[2] then urlPath = url:sub(urlSplit[3], urlSplit[4]) .. urlSplit[2] else urlPath = "" end else urlPath = url end local count = 0 local pathEnc = {} local delim = "" for part in mw.text.gsplit(urlPath, "[;/?:@&=+$,#]") do pathEnc[#pathEnc + 1] = delim pathEnc[#pathEnc + 1] = mw.uri.encode(mw.uri.decode(part, "PATH"), "PATH") count = count + #part + 1 delim = urlPath:sub(count, count) end return urlPre .. table.concat(pathEnc) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Thayts/1/doc
(
edit
)