manchenkoff/nuxt-auth-sanctum

[Bug] iOS 16.2 Safari doesn't support regex

Closed this issue · 4 comments

Describe the bug

Calling login throws an exception on Safari on iOS <17 (not including 17)

To Reproduce

  1. Open iOS 16.2 simulator on MacBook
  2. Try to login

Expected behavior

A network request is made to login to Laravel using sanctum.

Actual Behaviour

SyntaxError: Invalid regular expression: Invalid group specifier name

    return e.replace(new RegExp("(?<!^)\\/$"), "")

From source:

// src/runtime/utils/formatter.ts
export function trimTrailingSlash(path: string): string {
  return path.replace(/(?<!^)\/$/, '')
}

Module information

  • Version: v0.4.10

According to caniuse, the negative lookbehind regex support was adopted in iOS 16.4

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

Conversely, the proposed solution in #156 (String.length() & String.slice()) is supported in much earlier versions and more universally:
https://caniuse.com/mdn-javascript_builtins_string_length
https://caniuse.com/mdn-javascript_builtins_string_slice

This fix will be included in 0.4.11

Thanks a lot @manchenkoff

This is currently breaking our production for ios

@Cosnavel @olliescase version has been published, hope it will help to fix your prod! Feel free to re-open in case of further issues