Skip to content

Commit 6c97a7c

Browse files
Some more fixes
1 parent 51e5513 commit 6c97a7c

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

app/instance-initializers/hash-to-query-redirect.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import hashToQuery from 'hash-to-query';
22

33
export function initialize(application) {
4-
let redirectToUrl = hashToQuery();
5-
if (redirectToUrl) {
6-
window.location.href = window.location.origin + redirectToUrl;
7-
}
8-
window.onhashchange = function() {
9-
let router = application.lookup('service:router');
10-
let redirectToUrl = hashToQuery();
11-
if (redirectToUrl) {
12-
router.transitionTo(redirectToUrl);
4+
if (typeof FastBoot === 'undefined') {
5+
window.onhashchange = function() {
6+
let router = application.lookup('service:router');
7+
let redirectToUrl = hashToQuery();
8+
if (redirectToUrl) {
9+
router.transitionTo(redirectToUrl);
10+
}
1311
}
1412
}
1513
}

lib/hash-to-query/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ module.exports = {
1010

1111
included(app) {
1212
this._super.included.apply(this, arguments);
13-
this.import('vendor/hash-to-query/index.js');
13+
this.import('vendor/hash-to-query.js');
1414
}
1515
};

lib/hash-to-query/vendor/hash-to-query/index.js renamed to lib/hash-to-query/vendor/hash-to-query.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
(() => {
22
/* globals define */
33
function hashToQuery() {
4-
var hash = window && window.location && window.location.hash;
4+
let hash = window.location.hash;
55
if (hash && hash.length > 1) {
6-
var pathName = window.location.pathname;
6+
let pathName = window.location.pathname;
77
if (pathName.indexOf('/methods/') === -1 &&
88
pathName.indexOf('/properties/') === -1 &&
99
pathName.indexOf('/events/') === -1) {
10-
var type = hash.slice(1, hash.indexOf('_'));
11-
var name = hash.slice(hash.indexOf('_') + 1, hash.length);
12-
var anchor = '?anchor=' + name + '&show=inherited,protected,private,deprecated';
13-
var newPath = pathName;
10+
let type = hash.slice(1, hash.indexOf('_'));
11+
let name = hash.slice(hash.indexOf('_') + 1, hash.length);
12+
let anchor = '?anchor=' + name + '&show=inherited,protected,private,deprecated';
13+
let newPath = pathName;
1414
if (type === 'method') {
1515
newPath = pathName + '/methods/' + name;
1616
} else if (type === 'property') {
@@ -22,7 +22,12 @@
2222
}
2323
}
2424
}
25-
25+
if (typeof FastBoot === 'undefined') {
26+
let redirectToUrl = hashToQuery();
27+
if (redirectToUrl) {
28+
window.location.href = window.location.origin + redirectToUrl;
29+
}
30+
}
2631
define('hash-to-query', function () {
2732
'use strict';
2833
return {

0 commit comments

Comments
 (0)