Skip to content

Commit cb73933

Browse files
author
Kelly Selden
authored
early return and simplify path normalizing
1 parent 85d5281 commit cb73933

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

app/locations/none.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,32 @@ export default Ember.NoneLocation.extend({
2727
_response: readOnly('fastboot.response'),
2828
_request: readOnly('fastboot.request'),
2929

30-
_normalizePath(path, isInitialPath) {
31-
if (!isInitialPath) {
32-
// only on redirects (transitionTo, replaceWith, etc...)
33-
// incoming path does not include rootURL
34-
let rootURL = get(this, 'rootURL');
35-
rootURL = rootURL.substr(0, rootURL.length - 1);
36-
path = `${rootURL}${path}`;
37-
}
38-
return path;
30+
_normalizePath(path) {
31+
// only on redirects (transitionTo, replaceWith, etc...)
32+
// incoming path does not include rootURL
33+
let rootURL = get(this, 'rootURL');
34+
rootURL = rootURL.substr(0, rootURL.length - 1);
35+
return `${rootURL}${path}`;
3936
},
4037

4138
setURL(path) {
4239
if (get(this, 'fastboot.isFastBoot')) {
40+
let response = get(this, '_response');
4341
let currentPath = get(this, 'path');
4442
let isInitialPath = !currentPath || currentPath.length === 0;
45-
path = this._normalizePath(path, isInitialPath);
46-
let isTransitioning = currentPath !== path;
47-
let response = get(this, '_response');
4843

49-
if (isTransitioning && !isInitialPath) {
50-
let protocol = get(this, '_request.protocol');
51-
let host = get(this, '_request.host');
52-
let redirectURL = `${protocol}://${host}${path}`;
44+
if (!isInitialPath) {
45+
path = this._normalizePath(path);
46+
let isTransitioning = currentPath !== path;
47+
48+
if (isTransitioning) {
49+
let protocol = get(this, '_request.protocol');
50+
let host = get(this, '_request.host');
51+
let redirectURL = `${protocol}://${host}${path}`;
5352

54-
response.statusCode = this.get('_redirectCode');
55-
response.headers.set('location', redirectURL);
53+
response.statusCode = this.get('_redirectCode');
54+
response.headers.set('location', redirectURL);
55+
}
5656
}
5757

5858
// for testing and debugging

0 commit comments

Comments
 (0)