Skip to content

Instantly share code, notes, and snippets.

@willthames
Created March 3, 2020 02:38
Show Gist options
  • Save willthames/5faae957f58782826725bb242d2016ae to your computer and use it in GitHub Desktop.
Save willthames/5faae957f58782826725bb242d2016ae to your computer and use it in GitHub Desktop.
local tokenize = {}
function tokenize.tokenize(uri)
-- URLs that end in an ID
for _, path in ipairs({“/api/jobs, “/api/resources”}) do
if string.find(uri, path .. "/[^/]*") then
return string.gsub(uri, path .. "/.*", path .. "/{id}")
end
end
return uri
end
return tokenize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment