From 5e5c9f103dfd866ad5b6c1b99e1fcb049d11d189 Mon Sep 17 00:00:00 2001 From: Himanshu Date: Mon, 18 Feb 2019 19:23:19 +0530 Subject: [PATCH] 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_ --- frappe/public/js/frappe/router.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/router.js b/frappe/public/js/frappe/router.js index e79080cb3b..59bad0655d 100644 --- a/frappe/public/js/frappe/router.js +++ b/frappe/public/js/frappe/router.js @@ -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);