fix(router): Router Fix if Doc Name contains '?' (#6945)

- Router Show Page Not Found when there is a '?' in the doc name as it considers everything after '?' as argument

- When the name of doc is 'New' it considers as you are creating a new doc every time you visit it.

- After the fix, it checks if there is an '=' in name to check if there is an argument passed in the URL

- _Doesn't break the 'New' functionality_
This commit is contained in:
Himanshu 2019-02-18 19:23:19 +05:30 committed by Faris Ansari
parent dcc3d41d43
commit 5e5c9f103d

View file

@ -77,8 +77,15 @@ frappe.get_route = function(route) {
// for app
route = frappe.get_raw_route_str(route).split('/');
route = $.map(route, frappe._decode_str);
var parts = route[route.length - 1].split("?");
route[route.length - 1] = parts[0];
var parts = null;
var doc_name = route[route.length - 1];
// if the last part contains ? then check if it is valid query string
if(doc_name.indexOf("?") < doc_name.indexOf("=")){
parts = doc_name.split("?");
route[route.length - 1] = parts[0];
} else {
parts = doc_name;
}
if (parts.length > 1) {
var query_params = frappe.utils.get_query_params(parts[1]);
frappe.route_options = $.extend(frappe.route_options || {}, query_params);