diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 1b91a1bd..6a2d1c36 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -19,8 +19,8 @@ assignees: '' -- **Laravel version**: -- **Ziggy version**: +- **Laravel version**:  +- **Ziggy version**:  **Related routes**: @@ -30,9 +30,9 @@ assignees: '' Route::get('/', 'HomeController')->name('home'); ``` -**`Ziggy.namedRoutes`**: +**`Ziggy.routes`**: - + ```js { diff --git a/CHANGELOG.md b/CHANGELOG.md index ae94c782..4598a282 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Breaking changes are marked with ⚠️. - ⚠️ Default Ziggy's `baseUrl` to the value of the `APP_URL` environment variable instead of `url('/')` ([#334](https://github.com/tighten/ziggy/pull/334)) - ⚠️ Allow getting the route name with `current()` when the current URL has a query string ([#330](https://github.com/tighten/ziggy/pull/330)) - ⚠️ Return a literal string from the `route()` function when any arguments are passed to it ([#336](https://github.com/tighten/ziggy/pull/336)) +- ⚠️ Rename `namedRoutes` → `routes`, `defaultParameters` → `defaults`, `baseUrl` → `url`, and `basePort` → `port` ([#338](https://github.com/tighten/ziggy/pull/338)) **Deprecated** diff --git a/README.md b/README.md index 1cbe5e7c..0db27793 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Note that you still have to generate your routes file with `php artisan ziggy:ge ## Usage -This package uses the `@routes` directive to inject a JavaScript object containing all of your application's routes, keyed by their names. This collection is available at `Ziggy.namedRoutes`. +This package uses the `@routes` directive to inject a JavaScript object containing all of your application's routes, keyed by their names. This collection is available at `Ziggy.routes`. The package also creates an optional `route()` JavaScript helper that functions like Laravel's PHP `route()` helper, which can be used to retrieve URLs by name and (optionally) parameters. @@ -115,7 +115,7 @@ See the [Laravel documentation on default route parameter values](https://larave Default values work out of the box for Laravel versions >= 5.5.29, for previous versions you will need to set the default parameters by including this code somewhere in the same page as Ziggy's `@routes` Blade directive. ```js -Ziggy.defaultParameters = { +Ziggy.defaults = { // example locale: 'en', }; @@ -261,9 +261,9 @@ Route::get('/login', function () { // ziggy.js var Ziggy = { - namedRoutes: {"home":{"uri":"\/","methods":["GET","HEAD"],"domain":null},"login":{"uri":"login","methods":["GET","HEAD"],"domain":null}}, - baseUrl: 'http://ziggy.test/', - basePort: false + routes: {"home":{"uri":"\/","methods":["GET","HEAD"],"domain":null},"login":{"uri":"login","methods":["GET","HEAD"],"domain":null}}, + url: 'http://ziggy.test/', + port: null, }; export { diff --git a/src/BladeRouteGenerator.php b/src/BladeRouteGenerator.php index 5e35020c..bc57dbff 100644 --- a/src/BladeRouteGenerator.php +++ b/src/BladeRouteGenerator.php @@ -12,7 +12,7 @@ public function generate($group = false, $nonce = false) $nonce = $nonce ? ' nonce="' . $nonce . '"' : ''; if (static::$generated) { - return $this->generateMergeJavascript(json_encode($payload->toArray()['namedRoutes']), $nonce); + return $this->generateMergeJavascript(json_encode($payload->toArray()['routes']), $nonce); } $routeFunction = $this->getRouteFunction(); @@ -36,7 +36,7 @@ private function generateMergeJavascript($json, $nonce) var routes = {$json}; for (var name in routes) { - Ziggy.namedRoutes[name] = routes[name]; + Ziggy.routes[name] = routes[name]; } })(); diff --git a/src/CommandRouteGenerator.php b/src/CommandRouteGenerator.php index 6c9ff604..48161a7f 100644 --- a/src/CommandRouteGenerator.php +++ b/src/CommandRouteGenerator.php @@ -43,8 +43,8 @@ public function generate($group = false) var Ziggy = {$payload}; if (typeof window !== 'undefined' && typeof window.Ziggy !== 'undefined') { - for (var name in window.Ziggy.namedRoutes) { - Ziggy.namedRoutes[name] = window.Ziggy.namedRoutes[name]; + for (var name in window.Ziggy.routes) { + Ziggy.routes[name] = window.Ziggy.routes[name]; } } diff --git a/src/Ziggy.php b/src/Ziggy.php index e7ced410..d4ba9148 100644 --- a/src/Ziggy.php +++ b/src/Ziggy.php @@ -10,8 +10,8 @@ class Ziggy implements JsonSerializable { - protected $basePort; - protected $baseUrl; + protected $port; + protected $url; protected $group; protected $routes; @@ -19,8 +19,8 @@ public function __construct(string $group = null, string $url = null) { $this->group = $group; - $this->baseUrl = rtrim($url ?? config('app.url', url('/')), '/'); - $this->basePort = parse_url($this->baseUrl)['port'] ?? null; + $this->url = rtrim($url ?? config('app.url', url('/')), '/'); + $this->port = parse_url($this->url)['port'] ?? null; $this->routes = $this->nameKeyedRoutes(); } @@ -128,12 +128,12 @@ protected function nameKeyedRoutes() public function toArray(): array { return [ - 'baseUrl' => $this->baseUrl, - 'basePort' => $this->basePort, - 'defaultParameters' => method_exists(app('url'), 'getDefaultParameters') + 'url' => $this->url, + 'port' => $this->port, + 'defaults' => method_exists(app('url'), 'getDefaultParameters') ? app('url')->getDefaultParameters() : [], - 'namedRoutes' => $this->applyFilters($this->group)->toArray(), + 'routes' => $this->applyFilters($this->group)->toArray(), ]; } diff --git a/src/js/route.js b/src/js/route.js index 87f6a078..4f889334 100644 --- a/src/js/route.js +++ b/src/js/route.js @@ -28,8 +28,8 @@ class Route { // If we're building just a path there's no origin, otherwise: if this route has a // domain configured we construct the origin with that, if not we use the app URL const origin = !this.config.absolute ? '' : this.definition.domain - ? `${this.config.baseUrl.match(/^\w+:\/\//)[0]}${this.definition.domain}${this.config.basePort ? `:${this.config.basePort}` : ''}` - : this.config.baseUrl; + ? `${this.config.url.match(/^\w+:\/\//)[0]}${this.definition.domain}${this.config.port ? `:${this.config.port}` : ''}` + : this.config.url; return `${origin}/${this.definition.uri}`; } @@ -104,11 +104,11 @@ class Router extends String { this._config = config ?? Ziggy ?? globalThis?.Ziggy; if (name) { - if (!this._config.namedRoutes[name]) { + if (!this._config.routes[name]) { throw new Error(`Ziggy error: route '${name}' is not in the route list.`); } - this._route = new Route(name, this._config.namedRoutes[name], { ...this._config, absolute }); + this._route = new Route(name, this._config.routes[name], { ...this._config, absolute }); this._params = this._parse(params); } } @@ -157,7 +157,7 @@ class Router extends String { const url = window.location.host + window.location.pathname; // Find the first route that matches the current URL - const [current, route] = Object.entries(this._config.namedRoutes).find( + const [current, route] = Object.entries(this._config.routes).find( ([_, route]) => new Route(name, route, this._config).matchesUrl(url) ); @@ -189,7 +189,7 @@ class Router extends String { * @return {Object} */ get params() { - return this._dehydrate(this._config.namedRoutes[this.current()]); + return this._dehydrate(this._config.routes[this.current()]); } /** @@ -199,7 +199,7 @@ class Router extends String { * @return {Boolean} */ has(name) { - return Object.keys(this._config.namedRoutes).includes(name); + return Object.keys(this._config.routes).includes(name); } /** @@ -221,7 +221,7 @@ class Router extends String { params = ['string', 'number'].includes(typeof params) ? [params] : params; // Separate segments with and without defaults, and fill in the default values - const segments = route.parameterSegments.filter(({ name }) => !this._config.defaultParameters[name]); + const segments = route.parameterSegments.filter(({ name }) => !this._config.defaults[name]); if (Array.isArray(params)) { // If the parameters are an array they have to be in order, so we can transform them into @@ -256,8 +256,8 @@ class Router extends String { * @return {Object} Default route parameters. */ _defaults(route) { - return route.parameterSegments.filter(({ name }) => this._config.defaultParameters[name]) - .reduce((result, { name }, i) => ({ ...result, [name]: this._config.defaultParameters[name] }), {}); + return route.parameterSegments.filter(({ name }) => this._config.defaults[name]) + .reduce((result, { name }, i) => ({ ...result, [name]: this._config.defaults[name] }), {}); } /** @@ -304,7 +304,7 @@ class Router extends String { _dehydrate(route) { let pathname = window.location.pathname // If this Laravel app is in a subdirectory, trim the subdirectory from the path - .replace(this._config.baseUrl.replace(/^\w*:\/\/[^/]+/, ''), '') + .replace(this._config.url.replace(/^\w*:\/\/[^/]+/, ''), '') .replace(/^\/+/, ''); // Given part of a valid 'hydrated' URL containing all its parameter values, diff --git a/tests/Unit/BladeRouteGeneratorTest.php b/tests/Unit/BladeRouteGeneratorTest.php index 903ab94b..ae0b01ad 100644 --- a/tests/Unit/BladeRouteGeneratorTest.php +++ b/tests/Unit/BladeRouteGeneratorTest.php @@ -13,7 +13,7 @@ public function can_resolve_generator_from_container() { $generator = app(BladeRouteGenerator::class); - $this->assertStringContainsString('"namedRoutes":[]', $generator->generate()); + $this->assertStringContainsString('"routes":[]', $generator->generate()); } /** @test */ @@ -31,11 +31,11 @@ public function can_generate_named_routes() $output = (new BladeRouteGenerator)->generate(); $ziggy = json_decode(Str::after(Str::before($output, ";\n\n"), ' = '), true); - $this->assertCount(4, $ziggy['namedRoutes']); - $this->assertArrayHasKey('posts.index', $ziggy['namedRoutes']); - $this->assertArrayHasKey('posts.show', $ziggy['namedRoutes']); - $this->assertArrayHasKey('posts.store', $ziggy['namedRoutes']); - $this->assertArrayHasKey('postComments.index', $ziggy['namedRoutes']); + $this->assertCount(4, $ziggy['routes']); + $this->assertArrayHasKey('posts.index', $ziggy['routes']); + $this->assertArrayHasKey('posts.show', $ziggy['routes']); + $this->assertArrayHasKey('posts.store', $ziggy['routes']); + $this->assertArrayHasKey('postComments.index', $ziggy['routes']); } /** @test */ diff --git a/tests/Unit/RouteModelBindingTest.php b/tests/Unit/RouteModelBindingTest.php index 0e0190f4..7cd0cf0d 100644 --- a/tests/Unit/RouteModelBindingTest.php +++ b/tests/Unit/RouteModelBindingTest.php @@ -160,7 +160,7 @@ public function can_merge_implicit_and_scoped_bindings() 'tag' => 'slug', ], ], - ], (new Ziggy)->toArray()['namedRoutes']); + ], (new Ziggy)->toArray()['routes']); } /** @test */ @@ -170,7 +170,7 @@ public function can_include_bindings_in_json() $this->markTestSkipped('Requires Laravel >=7'); } - $json = '{"baseUrl":"http:\/\/ziggy.dev","basePort":null,"defaultParameters":[],"namedRoutes":{"users":{"uri":"users\/{user}","methods":["GET","HEAD"],"bindings":{"user":"uuid"}},"tags":{"uri":"tags\/{tag}","methods":["GET","HEAD"],"bindings":{"tag":"id"}},"tokens":{"uri":"tokens\/{token}","methods":["GET","HEAD"]},"users.numbers":{"uri":"users\/{user}\/{number}","methods":["GET","HEAD"],"bindings":{"user":"uuid"}},"posts":{"uri":"blog\/{category}\/{post}","methods":["GET","HEAD"],"bindings":{"category":"id","post":"slug"}},"posts.tags":{"uri":"blog\/{category}\/{post}\/{tag}","methods":["GET","HEAD"],"bindings":{"category":"id","post":"slug","tag":"slug"}}}}'; + $json = '{"url":"http:\/\/ziggy.dev","port":null,"defaults":[],"routes":{"users":{"uri":"users\/{user}","methods":["GET","HEAD"],"bindings":{"user":"uuid"}},"tags":{"uri":"tags\/{tag}","methods":["GET","HEAD"],"bindings":{"tag":"id"}},"tokens":{"uri":"tokens\/{token}","methods":["GET","HEAD"]},"users.numbers":{"uri":"users\/{user}\/{number}","methods":["GET","HEAD"],"bindings":{"user":"uuid"}},"posts":{"uri":"blog\/{category}\/{post}","methods":["GET","HEAD"],"bindings":{"category":"id","post":"slug"}},"posts.tags":{"uri":"blog\/{category}\/{post}\/{tag}","methods":["GET","HEAD"],"bindings":{"category":"id","post":"slug","tag":"slug"}}}}'; $this->assertSame($json, (new Ziggy)->toJson()); } diff --git a/tests/Unit/ZiggyTest.php b/tests/Unit/ZiggyTest.php index 34525c78..5831b537 100644 --- a/tests/Unit/ZiggyTest.php +++ b/tests/Unit/ZiggyTest.php @@ -95,7 +95,7 @@ public function can_set_included_routes_using_only_config() config(['ziggy' => [ 'only' => ['posts.s*', 'home'], ]]); - $routes = (new Ziggy)->toArray()['namedRoutes']; + $routes = (new Ziggy)->toArray()['routes']; $expected = [ 'home' => [ @@ -121,7 +121,7 @@ public function can_set_excluded_routes_using_except_config() config(['ziggy' => [ 'except' => ['posts.s*', 'home', 'admin.*'], ]]); - $routes = (new Ziggy)->toArray()['namedRoutes']; + $routes = (new Ziggy)->toArray()['routes']; $expected = [ 'posts.index' => [ @@ -146,7 +146,7 @@ public function returns_unfiltered_routes_when_both_only_and_except_configs_set( 'except' => ['posts.s*'], 'only' => ['home'], ]]); - $routes = (new Ziggy)->toArray()['namedRoutes']; + $routes = (new Ziggy)->toArray()['routes']; $expected = [ 'home' => [ @@ -188,7 +188,7 @@ public function can_set_included_routes_using_groups_config() 'authors' => ['home', 'posts.*'], ], ]]); - $routes = (new Ziggy('authors'))->toArray()['namedRoutes']; + $routes = (new Ziggy('authors'))->toArray()['routes']; $expected = [ 'home' => [ @@ -216,7 +216,7 @@ public function can_set_included_routes_using_groups_config() public function can_ignore_passed_group_not_set_in_config() { // The 'authors' group doesn't exist - $routes = (new Ziggy('authors'))->toArray()['namedRoutes']; + $routes = (new Ziggy('authors'))->toArray()['routes']; $expected = [ 'home' => [ @@ -256,7 +256,7 @@ public function can_include_middleware() config(['ziggy' => [ 'middleware' => true, ]]); - $routes = (new Ziggy)->toArray()['namedRoutes']; + $routes = (new Ziggy)->toArray()['routes']; $expected = [ 'home' => [ @@ -298,7 +298,7 @@ public function can_include_only_middleware_set_in_config() config(['ziggy' => [ 'middleware' => ['auth'], ]]); - $routes = (new Ziggy)->toArray()['namedRoutes']; + $routes = (new Ziggy)->toArray()['routes']; $expected = [ 'home' => [ @@ -341,7 +341,7 @@ public function can_order_fallback_routes_last() app('router')->get('/users', $this->noop())->name('users.index'); app('router')->getRoutes()->refreshNameLookups(); - $routes = (new Ziggy)->toArray()['namedRoutes']; + $routes = (new Ziggy)->toArray()['routes']; $expected = [ 'home' => [ @@ -391,10 +391,10 @@ public function route_payload_can_array_itself() $ziggy = new Ziggy; $expected = [ - 'baseUrl' => 'http://ziggy.dev', - 'basePort' => null, - 'defaultParameters' => [], - 'namedRoutes' => [ + 'url' => 'http://ziggy.dev', + 'port' => null, + 'defaults' => [], + 'routes' => [ 'home' => [ 'uri' => 'home', 'methods' => ['GET', 'HEAD'], @@ -422,7 +422,7 @@ public function route_payload_can_array_itself() ], ]; - $this->addPostCommentsRouteWithBindings($expected['namedRoutes']); + $this->addPostCommentsRouteWithBindings($expected['routes']); $this->assertSame($expected, $ziggy->toArray()); $this->assertSame($expected, $ziggy->jsonSerialize()); @@ -436,10 +436,10 @@ public function route_payload_can_json_itself() ]]); $expected = [ - 'baseUrl' => 'http://ziggy.dev', - 'basePort' => null, - 'defaultParameters' => [], - 'namedRoutes' => [ + 'url' => 'http://ziggy.dev', + 'port' => null, + 'defaults' => [], + 'routes' => [ 'postComments.index' => [ 'uri' => 'posts/{post}/comments', 'methods' => ['GET', 'HEAD'], @@ -447,9 +447,9 @@ public function route_payload_can_json_itself() ], ]; - $this->addPostCommentsRouteWithBindings($expected['namedRoutes']); + $this->addPostCommentsRouteWithBindings($expected['routes']); - $json = '{"baseUrl":"http:\/\/ziggy.dev","basePort":null,"defaultParameters":[],"namedRoutes":{"postComments.index":{"uri":"posts\/{post}\/comments","methods":["GET","HEAD"]}}}'; + $json = '{"url":"http:\/\/ziggy.dev","port":null,"defaults":[],"routes":{"postComments.index":{"uri":"posts\/{post}\/comments","methods":["GET","HEAD"]}}}'; if ($this->laravelVersion(7)) { $json = str_replace( diff --git a/tests/fixtures/admin.js b/tests/fixtures/admin.js index 0ca98ce6..1784a0f4 100644 --- a/tests/fixtures/admin.js +++ b/tests/fixtures/admin.js @@ -1,8 +1,8 @@ -var Ziggy = {"baseUrl":"http:\/\/ziggy.dev","basePort":null,"defaultParameters":[],"namedRoutes":{"admin.dashboard":{"uri":"admin","methods":["GET","HEAD"]}}}; +var Ziggy = {"url":"http:\/\/ziggy.dev","port":null,"defaults":[],"routes":{"admin.dashboard":{"uri":"admin","methods":["GET","HEAD"]}}}; if (typeof window !== 'undefined' && typeof window.Ziggy !== 'undefined') { - for (var name in window.Ziggy.namedRoutes) { - Ziggy.namedRoutes[name] = window.Ziggy.namedRoutes[name]; + for (var name in window.Ziggy.routes) { + Ziggy.routes[name] = window.Ziggy.routes[name]; } } diff --git a/tests/fixtures/custom-url.js b/tests/fixtures/custom-url.js index a87c5ee3..41781e9d 100644 --- a/tests/fixtures/custom-url.js +++ b/tests/fixtures/custom-url.js @@ -1,8 +1,8 @@ -var Ziggy = {"baseUrl":"http:\/\/example.org","basePort":null,"defaultParameters":{"locale":"en"},"namedRoutes":{"postComments.index":{"uri":"posts\/{post}\/comments","methods":["GET","HEAD"]}}}; +var Ziggy = {"url":"http:\/\/example.org","port":null,"defaults":{"locale":"en"},"routes":{"postComments.index":{"uri":"posts\/{post}\/comments","methods":["GET","HEAD"]}}}; if (typeof window !== 'undefined' && typeof window.Ziggy !== 'undefined') { - for (var name in window.Ziggy.namedRoutes) { - Ziggy.namedRoutes[name] = window.Ziggy.namedRoutes[name]; + for (var name in window.Ziggy.routes) { + Ziggy.routes[name] = window.Ziggy.routes[name]; } } diff --git a/tests/fixtures/ziggy.js b/tests/fixtures/ziggy.js index 2060be70..b1fd4ae0 100644 --- a/tests/fixtures/ziggy.js +++ b/tests/fixtures/ziggy.js @@ -1,8 +1,8 @@ -var Ziggy = {"baseUrl":"http:\/\/ziggy.dev","basePort":null,"defaultParameters":[],"namedRoutes":{"postComments.index":{"uri":"posts\/{post}\/comments","methods":["GET","HEAD"]}}}; +var Ziggy = {"url":"http:\/\/ziggy.dev","port":null,"defaults":[],"routes":{"postComments.index":{"uri":"posts\/{post}\/comments","methods":["GET","HEAD"]}}}; if (typeof window !== 'undefined' && typeof window.Ziggy !== 'undefined') { - for (var name in window.Ziggy.namedRoutes) { - Ziggy.namedRoutes[name] = window.Ziggy.namedRoutes[name]; + for (var name in window.Ziggy.routes) { + Ziggy.routes[name] = window.Ziggy.routes[name]; } } diff --git a/tests/js/route.test.js b/tests/js/route.test.js index 5317a91f..9aa12523 100644 --- a/tests/js/route.test.js +++ b/tests/js/route.test.js @@ -8,10 +8,10 @@ const defaultWindow = { }; const defaultZiggy = { - baseUrl: 'https://ziggy.dev', - basePort: null, - defaultParameters: { locale: 'en' }, - namedRoutes: { + url: 'https://ziggy.dev', + port: null, + defaults: { locale: 'en' }, + routes: { 'home': { uri: '/', methods: ['GET', 'HEAD'], @@ -173,7 +173,7 @@ describe('route()', () => { }); test('can error if a required parameter with a default has no default value', () => { - global.Ziggy.defaultParameters = {}; + global.Ziggy.defaults = {}; throws( () => route('translatePosts.index'), @@ -263,7 +263,7 @@ describe('route()', () => { }); test('can generate a URL for an app installed in a subfolder', () => { - global.Ziggy.baseUrl = 'https://ziggy.dev/subfolder'; + global.Ziggy.url = 'https://ziggy.dev/subfolder'; same( route('postComments.show', [1, { uuid: 'correct-horse-etc-etc' }]), @@ -342,8 +342,8 @@ describe('route()', () => { }); test('can generate a URL with a port', () => { - global.Ziggy.baseUrl = 'https://ziggy.dev:81'; - global.Ziggy.basePort = 81; + global.Ziggy.url = 'https://ziggy.dev:81'; + global.Ziggy.port = 81; // route with no parameters same(route('posts.index'), 'https://ziggy.dev:81/posts'); @@ -352,13 +352,13 @@ describe('route()', () => { }); test('can handle trailing path segments in the base URL', () => { - global.Ziggy.baseUrl = 'https://test.thing/ab/cd'; + global.Ziggy.url = 'https://test.thing/ab/cd'; same(route('events.venues.index', 1), 'https://test.thing/ab/cd/events/1/venues'); }); test('can URL-encode named parameters', () => { - global.Ziggy.baseUrl = 'https://test.thing/ab/cd'; + global.Ziggy.url = 'https://test.thing/ab/cd'; same( route('events.venues.index', { event: 'Fun&Games' }), @@ -389,10 +389,10 @@ describe('route()', () => { test('can accept a custom Ziggy configuration object', () => { const config = { - baseUrl: 'http://notYourAverage.dev', - basePort: false, - defaultParameters: { locale: 'en' }, - namedRoutes: { + url: 'http://notYourAverage.dev', + port: null, + defaults: { locale: 'en' }, + routes: { 'tightenDev.packages.index': { uri: 'tightenDev/{dev}/packages', methods: ['GET', 'HEAD'], @@ -407,7 +407,7 @@ describe('route()', () => { }); test('can extract parameters for an app installed in a subfolder', () => { - global.Ziggy.baseUrl = 'https://ziggy.dev/subfolder'; + global.Ziggy.url = 'https://ziggy.dev/subfolder'; global.window.location.href = 'https://ziggy.dev/subfolder/ph/en/products/4'; global.window.location.host = 'ziggy.dev'; @@ -417,7 +417,7 @@ describe('route()', () => { }); test('can extract parameters for an app installed in nested subfolders', () => { - global.Ziggy.baseUrl = 'https://ziggy.dev/nested/subfolder'; + global.Ziggy.url = 'https://ziggy.dev/nested/subfolder'; global.window.location.href = 'https://ziggy.dev/nested/subfolder/ph/en/products/4'; global.window.location.host = 'ziggy.dev'; @@ -506,9 +506,9 @@ describe('current()', () => { global.window.location.pathname = '/events/'; const config = { - baseUrl: 'https://ziggy.dev', - basePort: false, - namedRoutes: { + url: 'https://ziggy.dev', + port: null, + routes: { 'events.index': { uri: 'events', methods: ['GET', 'HEAD'], @@ -555,7 +555,7 @@ describe('current()', () => { }); test('can check the current route name on a route with optional parameters in the middle of the URI', () => { - global.Ziggy.baseUrl = 'https://ziggy.dev/subfolder'; + global.Ziggy.url = 'https://ziggy.dev/subfolder'; // Missing the optional 'language' parameter (e.g. subfolder/ph/en/products...) global.window.location.href = 'https://ziggy.dev/subfolder/ph/products/4';