Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Strange trailing character received from res.end

Strange trailing character received from res.end

Problem

Here's the backend code:

res.statusCode = 400
res.setHeader 'Content-Type', 'text/plain'
res.end 'Invalid API endpoint.'

When I curl it from terminal, I get:

Invalid API endpoint.%

the "%" sign shows up with inverted colors.

Why is that "%" sign there?

Problem courtesy of: Max

Solution

This marks a partial line, since the response send does not have a trailing newline. From

man zshoptions
    PROMPT_SP 
          Attempt  to  preserve  a partial line (i.e. a line that did not
          end with a newline) that would otherwise be covered up  by  the
          command prompt due to the PROMPT_CR option.  This works by out‐
          putting some cursor-control characters, including a  series  of
          spaces,  that  should  make  the terminal wrap to the next line
          when a partial line is present (note that this is only success‐
          ful if your terminal has automatic margins, which is typical).
          When  a  partial  line is preserved, by default you will see an
          inverse+bold character at the end of the partial line:   a  "%"
          for a normal user or a "#" for root.  If set, the shell parame‐
          ter PROMPT_EOL_MARK can be used to customize  how  the  end  of
          partial lines are shown.

          NOTE:  if the PROMPT_CR option is not set, enabling this option
          will have no effect.  This option is on by default.
Solution courtesy of: Jonathan Wiepert

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Strange trailing character received from res.end

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×