Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$location.url partially decodes url encoded string #15596

Closed
yasar11732 opened this issue Jan 11, 2017 · 3 comments
Closed

$location.url partially decodes url encoded string #15596

yasar11732 opened this issue Jan 11, 2017 · 3 comments

Comments

@yasar11732
Copy link

Here is simple example to demonstrate the problem;

<html>
  <head>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script>
  </head>
  
  <body ng-app="testapp" ng-controller="topcontroller">
      <script>
   (function(){
      'use strict'
      
      angular.module('testapp',[])
      .controller("topcontroller", function($location){
        var test_data = {"a":"123/65"};
        
        var routeparam = window.encodeURIComponent(JSON.stringify(test_data));
        console.log(routeparam);
        
        $location.url("/test/" + routeparam);
      })
      
    })();
   </script>
  </body>

</html>

while console.log(routeparam) outputs %7B%22a%22%3A%22123%2F65%22%7D I am being redirected to #/test/%7B%22a%22:%22123/65%22%7D. Notice the / character in redirected url. This behaviour affects how angular-route behaves because %7B%22a%22:%22123 and 65%22%7D parts are considered as path components.

@gkalpak
Copy link
Member

gkalpak commented Jan 11, 2017

Isn't this a duplicate of #13245 and/or #13815?

@yasar11732
Copy link
Author

As I workaround, I have decided to base64 encode my date instead of url encoding.

@gkalpak
Copy link
Member

gkalpak commented Jan 13, 2017

👍 Closing as duplicate.

@gkalpak gkalpak closed this as completed Jan 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants