Coder Social home page Coder Social logo

Comments (6)

bakerkretzmar avatar bakerkretzmar commented on August 19, 2024 1

I'll tag another release for this shortly. Thanks for your help @tmannherz!

from ziggy.

bakerkretzmar avatar bakerkretzmar commented on August 19, 2024

What's your actual route path? Is it at the root of your app's domain, so the entire URI is literally {catalog_uri}?

I'm adding tests for this to Ziggy and testing it in a real app too and I actually can't reproduce your exact examples. Laravel and Ziggy are behaving the same way for me, but they both behave differently if the route parameter is right at the root of the domain:

Route::get('{catalog_uri}', fn() => '')->where('catalog_uri', '^/p/.+$')->name('catalog1');

Route::get('catalog/{catalog_uri}', fn() => '')->where('catalog_uri', '^/p/.+$')->name('catalog2');

Both Laravel and Ziggy produce the same output for these:

route('catalog1', '/p/test'): http://example.com/p/test

route('catalog2', '/p/test'): http://example.com/catalog//p/test

from ziggy.

tmannherz avatar tmannherz commented on August 19, 2024

@bakerkretzmar The catalog routes are bound to a different domain, which is why these routes existing at all, so we can generate them correctly with the alternate domain.

Route::domain('catalog.example.com')->group(function () {
    Route::get('{catalog_uri}', fn() => view('pdp'))
        ->where('catalog_uri', '^/p/.+$')
        ->name('pdp');
});

Does that answer your question?

from ziggy.

bakerkretzmar avatar bakerkretzmar commented on August 19, 2024

Yeah it does, thanks. I can't reproduce this at all then. When I add a route with the exact configuration you shared to Ziggy's tests or to one of my own apps, Ziggy's route('catalog.pdp', { catalog_uri: '/p/test' }) returns http://example.com/p/test as expected. Tried on Laravel 10 and 11. Can you reproduce it in another app or a fresh install?

from ziggy.

tmannherz avatar tmannherz commented on August 19, 2024

@bakerkretzmar apologies...in my attempt to simply this for the ticket I actually removed the component that causes the issue. You're right that the scenario above works as expected.
I'm able to reproduce it with this slightly different route setup:

// catalog.php
Route::domain('{storefront}.example.com')->name('test.')->group(function () {
    Route::get('{catalog_uri}', fn() => view('pdp'))
        ->where('catalog_uri', '^/p/.+$')
        ->name('pdp');
});

Calling it like this in Vue:

<pre>
test pdp: {{
    route('catalog.test.pdp', {
        storefront: 'me',
        catalog_uri: '/p/test',
    })
}}
</pre>

Yields test pdp: https://me.example.com//p/test

For context, we run a multi-tenant site with multiple storefronts, each with its own subdomain.

from ziggy.

bakerkretzmar avatar bakerkretzmar commented on August 19, 2024

Thanks, I can reproduce that. Will investigate!

from ziggy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.