Skip to content

Commit c11b56c

Browse files
author
An Phan
committed
Docblock and refactor for GitHub badge
1 parent e0145c8 commit c11b56c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

app/site/src/components/Item.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ export default {
2929
props: ['item'],
3030
mixins: [filterByTag],
3131
computed: {
32+
/**
33+
* Get a shields.io badge URL for a GitHub repository.
34+
* @return {String|null}
35+
*/
3236
githubBadgeUrl() {
3337
const re = /https?:\/\/github\.com\/([A-Za-z0-9-_]*)\/([A-Za-z0-9-_]*)\/?$/i
3438
const matches = re.exec(this.item.url)
35-
if (!matches) {
36-
return null
37-
}
38-
39-
return `https://img.shields.io/github/stars/${matches[1]}/${matches[2]}.svg?style=social&label=★`
39+
return matches
40+
? `https://img.shields.io/github/stars/${matches[1]}/${matches[2]}.svg?style=social&label=★`
41+
: null
4042
}
4143
}
4244
}

0 commit comments

Comments
 (0)