Learn Lua · Data formats · Lesson 4 of 4
Web addresses
Values in a web address must be encoded: spaces and symbols become %XX codes.
url.encode_query builds the part after ? from a table, sorting the names so the result
is always the same, and url.decode_query reads it back:
url.encode_query({ q = "two words", page = 2 }) --> "page=2&q=two%20words"
url.decode_query("a=1&b=two+words") --> {a = "1", b = "two words"}
url.encode("a b&c") --> "a%20b%26c"What your code receives
Your code gets its data as input. The type Input line at the top of the code lists every field, and the editor uses it to suggest field names and spot typos. Here is an example. Each check sends different values, so work from the fields rather than these exact values.
input = { params = { q = "two words", page = 2 }, incoming = "size=a4&finish=matt+laminate" }Steps
- Return
query: the query text built frominput.params. - Add
link:"https://example.test/search?"followed by that query. - Add
params: the values in the query textinput.incoming, as a table.
Show a hint
Build the query once, keep it in a local, and use it for both query and link.