webmcp
annotate framework/env/request/set_absolute_baseurl.lua @ 67:937bbe05098c
Bugfix regarding compatibility with Lua 5.2:
return _M at end of mondelefant.lua
return _M at end of mondelefant.lua
| author | jbe |
|---|---|
| date | Tue Apr 17 15:39:27 2012 +0200 (2012-04-17) |
| parents | 9fdfb27f8e67 |
| children | 2169a62e12f5 |
| rev | line source |
|---|---|
| jbe/bsw@0 | 1 --[[-- |
| jbe/bsw@0 | 2 request.set_absolute_baseurl( |
| jbe/bsw@0 | 3 url -- Base URL of the application |
| jbe/bsw@0 | 4 ) |
| jbe/bsw@0 | 5 |
| jbe/bsw@0 | 6 Calling this function is neccessary for every configuration, because an absolute URL is needed for HTTP redirects. If the URL of the application is volatile, and if you don't bother violating the HTTP standard, you might want to execute request.set_absolute_baseurl(request.get_relative_baseurl()) in your application configuration. |
| jbe/bsw@0 | 7 |
| jbe/bsw@0 | 8 --]]-- |
| jbe/bsw@0 | 9 |
| jbe/bsw@0 | 10 function request.set_absolute_baseurl(url) |
| jbe/bsw@0 | 11 if string.find(url, "/$") then |
| jbe/bsw@0 | 12 request._absolute_baseurl = url |
| jbe/bsw@0 | 13 else |
| jbe/bsw@0 | 14 request._absolute_baseurl = url .. "/" |
| jbe/bsw@0 | 15 end |
| jbe/bsw@0 | 16 end |