Skip to content

Instantly share code, notes, and snippets.

@willthames
Created March 3, 2020 02:39
Show Gist options
  • Save willthames/ad5ab51bb2507cf96f52549bc6b6e84a to your computer and use it in GitHub Desktop.
Save willthames/ad5ab51bb2507cf96f52549bc6b6e84a 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