Input type email value in Chrome with accented characters wrong

后端 未结 3 1554
孤街浪徒
孤街浪徒 2021-01-17 16:51

When entering accented characters into an input type email in Chrome, it changes the value to something strange.

When entering the email: test@Bücher.ch th

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-17 17:46

    For others who face this problem again, I suggest use punycode npm package. https://www.npmjs.com/package/punycode

    I think only Chrome encodes email into punycode. There is no way to prevent Chrome from punycoding. You just let her do her work and decode punycode in backend.

    const punycode = require('punycode')
    let data = request.only(['email'])
    data['email'] = punycode.toUnicode(data['email'])
    

    Worked like charm in adonis and my headache disappeared.

提交回复
热议问题