Skip to content

Commit

Permalink
don't fail when fastBoot service does not exist (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoow authored Oct 29, 2019
1 parent 7251fb6 commit d663cf1
Show file tree
Hide file tree
Showing 2 changed files with 267 additions and 246 deletions.
12 changes: 8 additions & 4 deletions addon/services/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default Service.extend({
assert('Domain, Expires, Max-Age, and Path options cannot be set when reading cookies', isEmpty(options.domain) && isEmpty(options.expires) && isEmpty(options.maxAge) && isEmpty(options.path));

let all;
if (this._fastBoot.isFastBoot) {
if (this._isFastBoot()) {
all = this._getFastBootCookies();
} else {
all = this._getDocumentCookies();
Expand All @@ -78,7 +78,7 @@ export default Service.extend({

assert(`Cookies larger than ${MAX_COOKIE_BYTE_LENGTH} bytes are not supported by most browsers!`, this._isCookieSizeAcceptable(value));

if (this._fastBoot.isFastBoot) {
if (this._isFastBoot()) {
this._writeFastBootCookie(name, value, options);
} else {
assert('Cookies cannot be set to be HTTP-only from a browser!', !options.httpOnly);
Expand All @@ -99,7 +99,7 @@ export default Service.extend({

exists(name) {
let all;
if (this._fastBoot.isFastBoot) {
if (this._isFastBoot()) {
all = this._getFastBootCookies();
} else {
all = this._getDocumentCookies();
Expand Down Expand Up @@ -235,9 +235,13 @@ export default Service.extend({
},

_normalizedDefaultPath() {
if (!this._fastBoot.isFastBoot) {
if (!this._isFastBoot()) {
let pathname = window.location.pathname;
return pathname.substring(0, pathname.lastIndexOf('/'));
}
},

_isFastBoot() {
return this._fastBoot && this._fastBoot.isFastBoot;
}
});
Loading

0 comments on commit d663cf1

Please sign in to comment.