Actually fix the url generation

This commit is contained in:
Robin Malley 2021-02-13 18:40:17 +00:00
parent 4eb5b4a7bd
commit 67de40c02b
1 changed files with 18 additions and 0 deletions

View File

@ -110,6 +110,24 @@ function util.encode_id(number)
until number == 0 until number == 0
return table.concat(result) return table.concat(result)
end end
--[[
Legacy code, try to encode with invalid characters in the url first
]]
local new_encode = util.encode_id
function util.encode_id(number)
if number >= config.legacy_url_cutoff then
return new_encode(number)
else
local result = {}
local charlen = string.len(url_characters_legacy)
repeat
local pos = (number % charlen) + 1
number = math.floor(number / charlen)
table.insert(result,string.sub(url_characters_legacy,pos,pos))
until number == 0
return table.concat(result)
end
end
--[[ --[[
Given a short HTML-safe url path, convert it to a storyid Given a short HTML-safe url path, convert it to a storyid