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

Invalid regular expression: invalid group specifier name #38

Open
gitlobster opened this issue Jul 20, 2024 · 10 comments
Open

Invalid regular expression: invalid group specifier name #38

gitlobster opened this issue Jul 20, 2024 · 10 comments

Comments

@gitlobster
Copy link

Mobile Safari 14.1.2

Level: Error
Invalid regular expression: invalid group specifier name

https://caniuse.com/js-regexp-lookbehind

@ai
Copy link
Member

ai commented Jul 20, 2024

Show your router definition

@gitlobster
Copy link
Author

gitlobster commented Jul 20, 2024

const $router = createRouter({
  brands: '/brands/:value/:level2CategoryId?/:level3CategoryId?/:level4CategoryId?/:level5CategoryId?/',
  promo: '/promo/:value/:level2CategoryId?/:level3CategoryId?/:level4CategoryId?/:level5CategoryId?/',
  filter: [
    /\/catalog\/(.*)\/(.*)\/filter\/(.*)\/apply(.*)/,
    (rootCategory, level2CategoryId, smartFilterPath) => {
      return {
        rootCategory,
        level2CategoryId,
        smartFilterPath,
      }
    },
  ],
  section: [
    /\/catalog\/([^/]+)\/([^/]+)\/?([^/]*)\/?([^?]*)\/?([^?]*)/,
    (rootCategory, level2CategoryId, level3CategoryId, level4CategoryId) => {
      const clearLevel2 = level2CategoryId.replace(/\?.*/, '')
      const clearLevel3 = level3CategoryId.replace(/\?.*/, '')
      const clearLevel4 = level4CategoryId.replace(/\?.*/, '')
      return {
        rootCategory,
        level2CategoryId: clearLevel2,
        level3CategoryId: clearLevel3,
        level4CategoryId: clearLevel4,
      }
    }],
  actions: [
    /\/(actions)\/?([^/]*)\/?([^/]*)\/?([^/]*)\/?([^?]*)\/?([^?]*)/,
    (rootCategory, level2CategoryId, level3CategoryId, level4CategoryId) => {
      const clearLevel2 = level2CategoryId.replace(/\?.*/, '')
      const clearLevel3 = level3CategoryId.replace(/\?.*/, '')
      const clearLevel4 = level4CategoryId.replace(/\?.*/, '')
      return {
        rootCategory,
        level2CategoryId: clearLevel2,
        level3CategoryId: clearLevel3,
        level4CategoryId: clearLevel4,
      }
    }],
  cart: '/cart/',
  checkout: '/checkout/',
  'order-completed': '/checkout/:orderId',
  personal: '/my/',
  favorite: '/my/favorite/',
  compare: '/my/compare/',
  pickpoints: '/shops/',
  'pickpoints-city': '/shops/:city/',
  'pickpoints-pickpoint': '/shops/:city/:id/',
  delivery: '/delivery/',
  'delivery-city': '/delivery/:city/',
}, { links: false, search: true })

it's not spa, only some parts of site have logic on vue

@ai
Copy link
Member

ai commented Jul 20, 2024

Hm, regexp-lookbehind really fits our needs and I do not want to make code worse to support old browsers.

You can achieve the same result without using RegExp by combining string-based router with compute() (where you will clean params).

What do you think about it? Or why do you think we should support Safari 14?

@gitlobster
Copy link
Author

I have 8 such users in a couple of hours.
Yesterday, because of this mistake, we lost a customer buying a pair of lawn mowers

I don't know javascript so deeply that I can quickly rewrite the code, but in general, if not, then no

@gitlobster
Copy link
Author

image
Not only safari 14

@ai
Copy link
Member

ai commented Jul 20, 2024

To fix issue quickly you can downgrade @nanostores/routes to 0.14.x

@ai
Copy link
Member

ai commented Jul 20, 2024

Safari 0.15 is about 0.83 % in global market statistic (other browser in the list is just a skin for Safari, anyway it related to the browser).

What is your market? Why you have so many old iOS users?

@gitlobster
Copy link
Author

Version 14 contains this error too. I think the fact is that we have a lot of customers from the provinces, so there is so much old hardware

@ai
Copy link
Member

ai commented Jul 20, 2024

Got it! It is related with this PR #32

Move to 0.14.1.

But it fixed a real issue, I am not sure how we can revert it without breaking in another part.

@easing do you have any idea?

@gitlobster
Copy link
Author

playing with the library versions didn't help, but I tweaked it a little for the option, which is not entirely true, but fits my particular case

the next step is to change the code in my business logic, I think I understood how it would work in my case

thnks

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

2 participants