Skip to content

Resolve called twice when state url needs to be encoded #2408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bandrzejczak opened this issue Dec 3, 2015 · 2 comments
Closed

Resolve called twice when state url needs to be encoded #2408

bandrzejczak opened this issue Dec 3, 2015 · 2 comments

Comments

@bandrzejczak
Copy link

I've seen issue #37 which was resolved, but the problem still occurs if the state url needs to be encoded. Here's how it works:
If we have a state like this:

.state('state', {
        url: '/state/?path',
        templateUrl: 'template.html',
        resolve: {
          test: function ($stateParams) {
            console.log("Resolve called. Path = " + $stateParams.path);
          }
        }
      })

and have two links:

<a ui-sref="state({ path: 'testPath' })" translate>Test 1</a>
<a ui-sref="state({ path: '/testPath/' })" translate>Test 2</a>

Then for the first link resolve will be called once with path equal testPath, but for the second link resolve function will be called once for /testPath/ path and once for %2FtestPath%2F.

@eddiemonge
Copy link
Contributor

Im going to call this a duplicate of the #1973 (might not be the right one). Once the double encoding problem is fixed then if this isn't it can be reopened

@Bessonov
Copy link

Bessonov commented Oct 1, 2016

@eddiemonge

I still experience this issue with ui-router#0.2.18 if I use slug in urls:

.config(['$stateProvider', '$urlRouterProvider', '$urlMatcherFactoryProvider',
        function($stateProvider, $urlRouterProvider, $urlMatcherFactoryProvider) {
                $urlRouterProvider.otherwise('/');
                $urlMatcherFactoryProvider.type('slug', {
                        encode: function(str) { return str && str.replace(/ /g, '-'); },
                        decode: function(str) { return str && str.replace(/-/g, ''); },
                        is: angular.isString,
                        pattern: /[^/]+/
                });
        }
])

Is here any workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants