tighten / ziggy

Use your Laravel routes in JavaScript.
MIT License
3.83k stars 247 forks source link

False negative with route().current() and nested params #711

Closed fstrazzante closed 6 months ago

fstrazzante commented 6 months ago

Ziggy version

1.8.1

Laravel version

10.8

Description

When I try to check the current route with nested params, I got false but it should be true.

route: example.com/dashboard?filter[year]=2024 (I use spatie/laravel-query-builder)

on the page loaded on this route I did some tests:

  console.log("current params", route().params)
  console.log("current route", route().current('dashboard'))
  console.log("{ filter: { year: 2024 } }", route().current('dashboard', { filter: { year: 2024 } }))
  console.log("{ filter: { year: '2024' } }", route().current('dashboard', { filter: { year: '2024' } }))
  console.log("{ 'filter[year]': '2024' }", route().current('dashboard', { 'filter[year]': '2024' }))

And this is the result: image

Calling route().current('dashboard', { filter: { year: '2024' } } on route example.com/dashboard?filter[year]=2024 I expected to have true

Ziggy call and context

No error registered

Ziggy configuration

{
    "uri": "dashboard",
    "methods": [
        "GET",
        "HEAD"
    ]
}

Route definition

Route::get('dashboard', [DashboardController::class, 'index'])->name('dashboard');