http-request-in-editor icon indicating copy to clipboard operation
http-request-in-editor copied to clipboard

Input without empty lines is not parsing.

Open vitaliy-sk opened this issue 4 years ago • 3 comments

Describe the bug Input without empty lines at the end is not parsing. Simple input like GET https://test.com returns an empty array

To Reproduce

const { parse } = require('http-request-in-editor')


// Working
let input = `GET https://ifconfig.co/json` + '\n\n'

// NOT Working
let input = `GET https://ifconfig.co/json`

const cst = parse(input);
console.log(JSON.stringify(cst))

Expected behavior CST is returned for input without empty lines at the end of the input

vitaliy-sk avatar Aug 14 '21 20:08 vitaliy-sk

Thanks I have a look.

I was wondering - what's your usecase for using this library?

char0n avatar Aug 16 '21 13:08 char0n

Thanks I have a look.

I was wondering - what's your usecase for using this library?

Thanks, I'm investigating different options to implement standalone Inteliji like API client

vitaliy-sk avatar Aug 16 '21 15:08 vitaliy-sk

@vitaliy-sk I investigated and determined that the current behavior is correct.

request requires a new-line terminal to follow immediately after request-line. Without it, the ambiguity will appear. This parser is a canonical implementation of the http-request-in-editor specification.

Check the corpus for more examples.

I guess what we could possibly do is to inject CRFL at the end of the source string if it doesn't have one.

char0n avatar Aug 22 '21 13:08 char0n