Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conformToMask gives incorrect conformedValue on server-side #1033

Open
lennoximus opened this issue Dec 17, 2020 · 0 comments
Open

conformToMask gives incorrect conformedValue on server-side #1033

lennoximus opened this issue Dec 17, 2020 · 0 comments

Comments

@lennoximus
Copy link

Hello there!

I'm using vue-text-mask in my nuxtjs project. Due to some circumstances, I need to convert incoming phone strings to appropriate masked format and it's done in global store state aka vuex via certain getters. Now, to the main point.
So the goal is: if I get the +79514787749 string, I need to convert in +7 (951) 478-77-49. The approach is as follows:

import {conformToMask} from 'vue-text-mask'

export default function formatToMaskedPhone (value) {
  const conformedPhoneNumber = conformToMask(
    value,
    ['+', '7', ' ', '(', /\d/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, '-', /\d/, /\d/],
    {
      guide: false
    }
  )

  return conformedPhoneNumber.conformedValue
}

As a result, if I debug my code on server-side, I get +7 (/\d//\d//\d/) /\d//\d//\d/-/\d//\d/-/\d//\d/ in conformedValue instead of the desired formatted string. On client-side, though, when my store getters are reevaluated, the resulting string is computed as I want it to be.

What can be the case of this behaviour? I can try to make a repro later, if this can help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant