diff --git a/Makefile b/Makefile index c0ccfb7..716122a 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ build: - $(CC) -fPIC -c src/parser.c -o parser/http.so $(CFLAGS) + $(CC) -fPIC -c src/parser.c -o parser.o $(CFLAGS) + $(CC) -shared -o parser/http.so *.o diff --git a/grammar.js b/grammar.js index b4aba90..4df2b0e 100644 --- a/grammar.js +++ b/grammar.js @@ -16,9 +16,7 @@ module.exports = grammar(json, { request: ($) => seq(field("method", $.method), $._whitespace, field("url", $.url)), - method: (_) => /(GET|POST|PATCH|DELETE|PUT)/, - url: (_) => /((www|http:|https:)\/\/(?:w{1,3}\.)?[^\s.]+(?:\.[a-z]+)*(?::\d+)?|\{\{\w+\}\})([\w.,@?^=%&:\/~+#\{\}\u00C0-\u00FF-]*[\w@?^=%&\/~+#\u00C0-\u00FF-])?/, @@ -28,19 +26,17 @@ module.exports = grammar(json, { $._whitespace, field("value", $.value) ), - name: (_) => /[A-Za-z-]+/, - value: (_) => /[^\n]+/, - json_file: (_) => seq(/[A-Za-z-_./]+/, ".json"), - external_body: ($) => seq( token("<"), $._whitespace, field("json_file", $.json_file), ), + json_file: (_) => seq(/[A-Za-z-_./]+/, ".json"), + comment: ($) => token(seq("#", /.*/)), diff --git a/tests/multiple_requests.http b/tests/multiple_requests.http new file mode 100644 index 0000000..b57ca44 --- /dev/null +++ b/tests/multiple_requests.http @@ -0,0 +1,20 @@ +POST https://reqres.in/api/users +Content-Type: application/json + +{ + "name": "morpheus", + "job": "leader", + "array": ["a", "b", "c"], + "object_ugly_closing": { + "some_key": "some_value" +} +} + +POST https://reqres.in/api/users +Content-Type: application/json + +< ./user.json + +#### +### +GET https://reqres.in/api/users?page=5