From cf6f6147ae8792b2dfb16bfb7ec905ea235ebc52 Mon Sep 17 00:00:00 2001 From: Ben Keen Date: Thu, 18 Jun 2015 10:24:07 -0700 Subject: [PATCH] Fix for relative link handling issue in test environment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's an issue with our current beta where clicking on a View name in the new React sidebar doesn't redirect the user to that view, but just shrinks the view section. Michelle got a fix in place in this PR: https://github.com/apache/couchdb-fauxton/pull/463. It works fine, but I didn't want to have to cancel events any time this occurs. After some digging, we found that this issue only occurs on dashboard.xxx/dashboard.html environments. It works fine locally, and wouldn't occur on prod. But it's a Fauxton issue. The issue is that the modified line of code in this PR was determining whether a link should be handled via the backbone router by comparing the base of the URL, including the dashboard.xxx/dashboard.assets folder. That would always fail to be true on beta environments because no link linked to the dashboard.assets folder. So remarkably, the navigate() line wasn’t running at all for any link on the dashboard.xxx environments, but links still worked because the router independently listened to the hash changes and handled the routing. The only difference was that the event wasn’t canceled, which caused the issue described above. I think the change made in this PR is safe. The purpose of the line is to determine "relative" links (or rather links within Fauxton), so I just made it a little more generic by comparing the http://whatever:port/ part, and not http://whatever:port/subfolder/ part. Michelle mentioned there have been other instances where we seem to need to cancel events like this. This should solve that. Hope this is clear. --- app/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/main.js b/app/main.js index d5d903c1e..15c585c4e 100644 --- a/app/main.js +++ b/app/main.js @@ -34,8 +34,8 @@ function (app, FauxtonAPI, LoadAddons) { // Get the absolute anchor href. var href = { prop: $(this).prop("href"), attr: $(this).attr("href") }; - // Get the absolute root. - var root = location.protocol + "//" + location.host + app.root; + // Get the absolute root + var root = location.protocol + "//" + location.host; // Ensure the root is part of the anchor href, meaning it's relative if (href.prop && href.prop.slice(0, root.length) === root) {