Mercurial Hosting > luan
comparison src/luan/modules/http/Http_test.luan @ 1716:b82767112d8e
add String.regex
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 24 Jul 2022 23:43:03 -0600 |
parents | d9a5405a3102 |
children |
comparison
equal
deleted
inserted
replaced
1715:ad44e849c60c | 1716:b82767112d8e |
---|---|
2 local error = Luan.error | 2 local error = Luan.error |
3 local set_metatable = Luan.set_metatable or error() | 3 local set_metatable = Luan.set_metatable or error() |
4 local Package = require "luan:Package.luan" | 4 local Package = require "luan:Package.luan" |
5 local Io = require "luan:Io.luan" | 5 local Io = require "luan:Io.luan" |
6 local String = require "luan:String.luan" | 6 local String = require "luan:String.luan" |
7 local matches = String.matches or error() | 7 local ends_with = String.ends_with or error() |
8 local Http = require "luan:http/Http.luan" | 8 local Http = require "luan:http/Http.luan" |
9 | 9 |
10 | 10 |
11 local Http_test = {} | 11 local Http_test = {} |
12 | 12 |
13 Http_test.welcome_file = "index.html" | 13 Http_test.welcome_file = "index.html" |
14 Http_test.cookies = {} | 14 Http_test.cookies = {} |
15 | 15 |
16 function Http_test.get_page(path) | 16 function Http_test.get_page(path) |
17 Http.request.path = path | 17 Http.request.path = path |
18 if Http_test.welcome_file ~= nil and matches(path,"/$") then | 18 if Http_test.welcome_file ~= nil and ends_with(path,"/") then |
19 path = path .. Http_test.welcome_file | 19 path = path .. Http_test.welcome_file |
20 end | 20 end |
21 local old_out = Io.stdout | 21 local old_out = Io.stdout |
22 try | 22 try |
23 local mod = Package.load("site:"..path..".luan") or error(path.." not found") | 23 local mod = Package.load("site:"..path..".luan") or error(path.." not found") |