Skip to content

Commit

Permalink
Avoid console error in add-releases-tab
Browse files Browse the repository at this point in the history
Fixes #901
  • Loading branch information
fregante committed May 25, 2018
1 parent 622a92b commit 7df0a1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 6 additions & 4 deletions source/features/add-releases-tab.js
@@ -1,5 +1,5 @@
import select from 'select-dom';
import {h} from 'dom-chef';
import select from 'select-dom';
import * as icons from '../libs/icons';
import * as pageDetect from '../libs/page-detect';
import {registerShortcut} from './improve-shortcut-help';
Expand All @@ -20,9 +20,11 @@ function appendReleasesCount(count) {

function updateReleasesCount() {
if (pageDetect.isRepoRoot()) {
const releasesCount = select('.numbers-summary a[href$="/releases"] .num').textContent.trim();
localCache = {[repoKey]: releasesCount};
browser.storage.local.set(localCache);
const releasesCount = select('.numbers-summary a[href$="/releases"] .num');
if (releasesCount) {
localCache = {[repoKey]: Number(releasesCount.textContent)};
browser.storage.local.set(localCache);
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion test/page-detect.js
Expand Up @@ -368,9 +368,12 @@ test('isRepoTree', urlMatcherMacro, pageDetect.isRepoTree, [
'https://github.com/sindresorhus/refined-github/tree/master/distribution',
'https://github.com/sindresorhus/refined-github/tree/0.13.0/distribution',
'https://github.com/sindresorhus/refined-github/tree/57bf435ee12d14b482df0bbd88013a2814c7512e/distribution',
'https://github.com/sindresorhus/refined-github/tree/57bf4'
'https://github.com/sindresorhus/refined-github/tree/57bf4',
'https://github.com/sindresorhus/refined-github?files=1',
'https://github.com/sindresorhus/refined-github/tree/master?files=1'
], [
'https://github.com/sindresorhus/refined-github/issues',
'https://github.com/sindresorhus/refined-github/issues?files=1',
'https://github.com/sindresorhus/refined-github/blob/tree/master/distribution'
]);

Expand Down

0 comments on commit 7df0a1e

Please sign in to comment.