Skip to content

Commit

Permalink
controllers: improvement of location update
Browse files Browse the repository at this point in the history
Signed-off-by: Pamfilos Fokianos <pamfilosf@gmail.com>
  • Loading branch information
pamfilos committed Nov 3, 2016
1 parent 3e9f31c commit 147bfa3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/invenio-records-js/controllers/InvenioRecordsCtrl.js
Expand Up @@ -416,13 +416,18 @@ function InvenioRecordsCtrl($scope, $rootScope, $q, $window, $location,
* @param {Object} endpoints - The object with the endpoints.
*/
function invenioRecordsLocationUpdated(evt, endpoints) {
// Change the location only if html exists
if (!angular.isUndefined(endpoints.html)) {
// ¯\_(ツ)_/¯ https://github.com/angular/angular.js/issues/3924
var parser = document.createElement('a');
parser.href = endpoints.html;
$location.url(parser.pathname);
$location.replace();
// Get the pathname of localhost
var _current = document.createElement('a');
_current.href = $location.path();
// Get the pathname of endpoints
var _endpoints = document.createElement('a');
_endpoints.href = endpoints.html;
// Check if are the same
if (_endpoints.pathname !== _current.pathname) {
$location.url(_endpoints.pathname);
$location.replace();
}
}
}

Expand Down

0 comments on commit 147bfa3

Please sign in to comment.