You are reading a single comment by @iwae and its replies. Click here to read the full conversation.
  • Hi guys,

    i have a problem with sending some data with an simple http form.

    HTML Code:

    
    > <html> 
    > <head><meta charset="utf-8"/></head>   
    > <body><h2>Konfiguration</h2> <form  action="#" method="post"> > <div class="container">
    > <label for="test"><b>TEST</b></label><input type="text" placeholder="Enter text" name="test" required>
    > </form>
    > </body>
    > </html>
    
    

    JS on Espruino

      var data = "";
      req.on('data', function(d) { data += d; });
      req.on('end', function() {
        postData = {};
        console.log(data);
        data.split("&").forEach(function(el) {
          var els = el.split("=");
          postData[els[0]] = decodeURIComponent(els[1]);
        });
    

    If I enter the following to the form: "PLUS++++LEER OK"
    The browser send: "PLUS%2B%2B%2B%2BLEER+++++OK"

    On espruino: test=PLUS%2B%2B%2B%2BLEER+++++OK
    Now I call the "decodeURIComponent" but the result is
    "PLUS++++LEER+++++OK"

    I would expect the following: "PLUS++++LEER OK"
    https://www.w3schools.com/tags/att_form_­enctype.asp

    You have the same behaviour? The blank issnt decoded correctly.

About

Avatar for iwae @iwae started