Keep small prefix inlined in call chain#550
Merged
JohnnyMorganz merged 4 commits intomainfrom Aug 21, 2022
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## main #550 +/- ##
==========================================
- Coverage 97.80% 97.80% -0.01%
==========================================
Files 14 14
Lines 5420 5419 -1
==========================================
- Hits 5301 5300 -1
Misses 119 119
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Contributor
Repo Comparison Testdiff --git ORI/luvit/examples/http-server-todo-web.lua ALT/luvit/examples/http-server-todo-web.lua
index de3c1df..c08beea 100644
--- ORI/luvit/examples/http-server-todo-web.lua
+++ ALT/luvit/examples/http-server-todo-web.lua
@@ -2,22 +2,20 @@ local http = require("http")
local url = require("url")
local items = {}
-- see Node.js_in_action.pdf : page 89 (110 of 417)
-http
- .createServer(function(req, res)
- --p(req)
- if req.url == "/" then
- if req.method == "GET" then
- show(res)
- elseif req.method == "POST" then
- add(req, res)
- else
- badRequest(res)
- end
+http.createServer(function(req, res)
+ --p(req)
+ if req.url == "/" then
+ if req.method == "GET" then
+ show(res)
+ elseif req.method == "POST" then
+ add(req, res)
else
- notFound(res)
+ badRequest(res)
end
- end)
- :listen(8080)
+ else
+ notFound(res)
+ end
+end):listen(8080)
function map(a, fcn)
local b = {}
diff --git ORI/luvit/examples/http-upload.lua ALT/luvit/examples/http-upload.lua
index e800d5a..5950c9d 100644
--- ORI/luvit/examples/http-upload.lua
+++ ALT/luvit/examples/http-upload.lua
@@ -2,27 +2,25 @@ local http = require("http")
local utils = require("utils")
local table = require("table")
-http
- .createServer(function(req, res)
- p("on_request", req)
- local chunks = {}
- local length = 0
- req:on("data", function(chunk, len)
- p("on_data", { len = len })
- length = length + 1
- chunks[length] = chunk
- end)
- req:on("end", function()
- local body = table.concat(chunks, "")
- p("on_end", { total_len = #body })
- body = "length = " .. tostring(#body) .. "\n"
- res:writeHead(200, {
- ["Content-Type"] = "text/plain",
- ["Content-Length"] = #body,
- })
- res:finish(body)
- end)
+http.createServer(function(req, res)
+ p("on_request", req)
+ local chunks = {}
+ local length = 0
+ req:on("data", function(chunk, len)
+ p("on_data", { len = len })
+ length = length + 1
+ chunks[length] = chunk
end)
- :listen(8080)
+ req:on("end", function()
+ local body = table.concat(chunks, "")
+ p("on_end", { total_len = #body })
+ body = "length = " .. tostring(#body) .. "\n"
+ res:writeHead(200, {
+ ["Content-Type"] = "text/plain",
+ ["Content-Length"] = #body,
+ })
+ res:finish(body)
+ end)
+end):listen(8080)
print("Server listening at http://localhost:8080/")
diff --git ORI/luvit/tests/test-url.lua ALT/luvit/tests/test-url.lua
index 105e660..88a1867 100644
--- ORI/luvit/tests/test-url.lua
+++ ALT/luvit/tests/test-url.lua
@@ -86,7 +86,11 @@ local relativeTests = {
"https://u:p@h.com/p/a/t/h?s#hash2",
},
{ "http://example.com/b//c//d;p?q#blarg", "https://a/b/c/d", "https://a/b/c/d" },
- { "http://example.com/b//c//d;p?q#blarg", "http://u:p@h.com/p/a/t/h?s#hash2", "http://u:p@h.com/p/a/t/h?s#hash2" },
+ {
+ "http://example.com/b//c//d;p?q#blarg",
+ "http://u:p@h.com/p/a/t/h?s#hash2",
+ "http://u:p@h.com/p/a/t/h?s#hash2",
+ },
{ "/foo/bar/baz", "/../etc/passwd", "/etc/passwd" },
{ "http://localhost", "file://foo/Users", "file://foo/Users" },
-- from node
diff --git ORI/lit/commands/serve.lua ALT/lit/commands/serve.lua
index 38e6078..183600b 100644
--- ORI/lit/commands/serve.lua
+++ ALT/lit/commands/serve.lua
@@ -38,10 +38,8 @@ return function()
end)
app.use(require("weblit-auto-headers"))
-.route({ method = "GET", path = "/snapshots" }, require("snapshots")).route(
- { method = "GET", path = "/stats" },
- require("stats")
- )
+ .route({ method = "GET", path = "/snapshots" }, require("snapshots"))
+ .route({ method = "GET", path = "/stats" }, require("stats"))
-- Handle websocket clients
app.websocket({
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #514