diff -r 1b8b29c0e95c -r 245b4df137d3 common/corpus-common-addon/addon/components/doc-subject.js --- a/common/corpus-common-addon/addon/components/doc-subject.js Tue Dec 13 23:30:54 2016 +0100 +++ b/common/corpus-common-addon/addon/components/doc-subject.js Fri Dec 16 17:43:07 2016 +0100 @@ -3,39 +3,44 @@ import layout from '../templates/components/doc-subject'; export default Ember.Component.extend({ - layout: layout, - tagName: "span", - displayLabel: Ember.computed('label', 'resolvedLabel', function() { - return this.get('label') || this.get('resolvedLabel'); - }), - bnfResolver: Ember.inject.service(), + layout: layout, + tagName: 'span', + displayLabel: Ember.computed('label', 'resolvedLabel', function () { + return this.get('label') || this.get('resolvedLabel'); + }), + bnfResolver: Ember.inject.service(), - _resolveBnfIds: Ember.on('init', Ember.observer('url', 'label', function() { - if(this.get('label')) { - if (!(this.get('isDestroyed') || this.get('isDestroying'))) { - this.set('resolvedLabel', this.get('label')); - } - return; + _resolveBnfIds: Ember.on('init', Ember.observer('url', 'label', function () { + if (this.get('label')) { + if (!(this.get('isDestroyed') || this.get('isDestroying'))) { + this.set('resolvedLabel', this.get('label')); } - this.get('bnfResolver').getLabel(this.get('url')).then(function(str) { - if (!(this.get('isDestroyed') || this.get('isDestroying'))) { - this.set('resolvedLabel', str); - } - }.bind(this)); - })), + + return; + } + if (this.get('bnfResolver')) { + this.get('bnfResolver').getLabel(this.get('url')) + .then(function (str) { + if (!(this.get('isDestroyed') || this.get('isDestroying'))) { + this.set('resolvedLabel', str); + } + }.bind(this)); + } + })), - code: Ember.computed('url', function() { - var rawSubject = this.get('url'); - if(rawSubject) { - if(rawSubject.startsWith(constants.BNF_BASE_URL)) { - return rawSubject.substr(constants.BNF_BASE_URL.length); - } - else if (rawSubject.startsWith(constants.BNF_ARK_BASE_URL)) { - return rawSubject.substr(constants.BNF_ARK_BASE_URL.length); - } + code: Ember.computed('url', function () { + const rawSubject = this.get('url'); + + if (rawSubject) { + if (rawSubject.startsWith(constants.BNF_BASE_URL)) { + return rawSubject.substr(constants.BNF_BASE_URL.length); + } else if (rawSubject.startsWith(constants.BNF_ARK_BASE_URL)) { + return rawSubject.substr(constants.BNF_ARK_BASE_URL.length); } - return rawSubject; - }), - isSubjectLink: Ember.computed.match('url', /^http\:\/\//) + } + + return rawSubject; + }), + isSubjectLink: Ember.computed.match('url', /^http\:\/\//) });