Lua v2 Location

This global table holds data about the URL/location.

location.href
Properties Values
Editable No

Contents

  • href - The complete URL buss://website.it/path?query=params
  • domain - The domain website.it
  • protocol - The protocol buss
  • path - Path /path
  • query - Query parameters { query: 'params and stuff' }
  • rawQuery - Unparsed query parameters ?query=params%20and%20stuff
  • go(url) - Redirect to another URL

Query

The query is a table with key being the param name and value its value. Some important things:

  • Duplicate last overwrites others. ?cat=1&cat=2 then { cat: '2' }.
  • Case sensitive. ?Cat=1&cat=2 then { Cat: '1', cat: '2' }.
  • Multi = are not ignored. ?cat=1=2 then { cat: '1=2' }.
  • Special characters are decoded. ?kitty%20cat=makes%20meow then { 'kitty cat': 'makes meow' }.
  • Trailing spaces are not trimmed. ? cat = 1 then { ' cat ': ' 1 ' }.
  • Blank values are fine but blank keys are not. ?cat=&=cat&dog&&= then { cat: '', dog: '' }.
  • Trailing ? & are ignored. ?cat& then { cat: '' } or ? then {}.

Support

  YAB WXV Core
location None 1
href None 1
domain None 1
protocol None 1
path None 1
query None 1
rawQuery None 1
go None 1