ui-router icon indicating copy to clipboard operation
ui-router copied to clipboard

$stateParams not decodeURIComponent @v0.2.15

Open hzdorian opened this issue 11 years ago • 4 comments

my router looks like this:

'app.external': {
    url: "/external/{url:.*}",
    views: {
        'screen': {
            controller: function($scope, $state, $stateParams) {
                if (!$state.params.url) {
                    $state.go('app.external', {
                        url: 'http://www.1688.com/'
                    });
                    return;
                }
                console.log($stateParams); // {url: "http:%2F%2Fwww.1688.com%2F"}
            }
        }
    }
}

while, the param $stateParams equals {url: "http:%2F%2Fwww.1688.com%2F"}

when debugging through angular-ui-router.js, I found that both $state.go() and handleIfMatch() (line L2346 ) invoke the $state.transitionTo again, but the var toParams are not the same.

but when I change the param url to an other string such as 阿里巴巴, www.1688.com, I works.

BTW: version v0.2.13 performs well.

hzdorian avatar Jul 16 '15 09:07 hzdorian

I'm experiencing this problem also. Can confirm that v0.2.13 performs fine.

I found that I was able to get some logging on it:

$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
  // console.log("from:", fromState.name);
  // console.log(JSON.stringify(fromParams, null, "  "));
  // console.log("to:", toState.name);
  // console.log(JSON.stringify(toParams, null, "  "));
});

Any time I navigated to a state, $stateChangeStart would get fired twice — once with a URI-decoded version of the state, and once with a URI-encoded version of the same state.

Wondering what changed in (v0.2.14? v0.2.15?) that could account for this.

billforward-alex avatar Aug 04 '15 10:08 billforward-alex

See also: https://github.com/angular-ui/ui-router/issues/2172

quoideneuf avatar Aug 14 '15 01:08 quoideneuf

pretty sure this is a duplicate of params encoding issue.

eddiemonge avatar Aug 18 '15 20:08 eddiemonge

+1. I put a normal url in, and get an encoded url out. Not useful.

michaelabuckley avatar Sep 16 '15 19:09 michaelabuckley