visionmedia / page.js

Micro client-side router inspired by the Express router
http://visionmedia.github.com/page.js
7.68k stars 688 forks source link

Page.js triggered on call to diferent domain #407

Closed cristiancs closed 6 years ago

cristiancs commented 7 years ago

If i have a website example.com and have a link to example.com.co the page.js trigger is executed.

paulocoghi commented 7 years ago

Can you post the code you are using?

The correct behavior is not to interfere with links to different domains.

cristiancs commented 7 years ago
page('/:first/:second/:page',goBack);
page('/:first/:second',goBack)

function goBack(ctx,next){

        if(!actual.called){
            actual.called = true;
            actual.first = ctx.params.first;
            actual.second = ctx.params.second;
        }
        else{
            console.log(ctx);
            window.location.href = ctx.path;
        }

    }

Actually i only do this code to fix another bug (when clicking go back on the browser it doesn't work).

The code works well when you link to example.ru by example, but if it is .com.ru its trigger page.js.

matthewp commented 6 years ago

Thanks, this is an interesting one, I'll try to take a look at it soon.