0

I want to pass an email address as a query string and as such I encode it just before sending it with this line of code:

var encoded = encodeURIComponent(email).replace('.' '%2E');

Apparently the period shouldn't matter but I keep getting "can't find module 'com' " if i run it that way (I'm coding on node and using express and using a res.render() call)

Don't really understand why in my case periods are causing issues but either way this is the exact error I get:

    var encoded = encodeURIComponent(email).replace('.' '%2E');
                                                        ^^^^^
SyntaxError: Unexpected string
3
  • 4
    Umm...You don't have a comma... Commented Dec 18, 2013 at 22:54
  • 1
    "SyntaxError: Unexpected string" pointing to the string that was unexpected wasn't clear? Commented Dec 18, 2013 at 22:56
  • It's been a long day!! Knew it was referring to there but thought it had to do with weird replace dynamics with .replace or something Commented Dec 18, 2013 at 23:54

1 Answer 1

6

Don't really understand why in my case periods are causing issues

It's not the presence of a period. It's the lack of a comma.

var encoded = encodeURIComponent(email).replace('.', '%2E');
//                                                 ^ this here
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.