Skip to content

Problem with negative look-behind causing Safari to explode #812

@tholder

Description

@tholder

Ziggy version

2.x

Laravel version

11

Description

I'm using Laravel with Inertia and React.

It's the (?i:BASE64|) part of the route and I believe it is because safari doesn't support a negative look-behind. Before I discovered the offending route (as safari is such a pain to debug in), I did manage to eliminate it with an amend on atomica-software#1

Fix is easy enough for me, but this is a nasty safari only problem that could catch people out.

Some references:

https://stackoverflow.com/questions/51568821/works-in-chrome-but-breaks-in-safari-invalid-regular-expression-invalid-group
https://caniuse.com/js-regexp-lookbehind

Ziggy call and context

Simple call to route().params.team

Could potentially just be useRoute() call. Had some issue determining this.

Ziggy configuration

"image.avatar": {
            "uri": "image/{type}/{id}/{hash}/{format?}",
            "methods": [
                "GET",
                "HEAD"
            ],
            "wheres": {
                "id": "[0-9]+|[0-9a-f\\-]+",
                "type": "user|contact",
                "format": "(?i:BASE64)|"
            },
            "parameters": [
                "type",
                "id",
                "hash",
                "format"
            ]
        },

Trimmed for sensitivity but this is the route causing a problem.

Route definition

Route::get('/image/{type}/{id}/{hash}/{format?}', [ImageResourceController::class, 'show'])
    ->name('image.avatar')
    ->where('type', 'user|contact')
    ->where('id', '[0-9]+|[0-9a-f\-]+')
    ->where('format', '(?i:BASE64)|')
    ->withoutMiddleware(['web']);

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions