core: optional input

This commit is contained in:
undefined committed 2021-04-20 00:38:44 +08:00
1 parent ce880b4e05
commit 30710cdbfb
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ export const providers: Record<string, AvatarProvider> = {
};
function avatar(src: string, size = 64) {
const index = src.indexOf(':');
const index = (src || '').indexOf(':');
if (index === -1) return providers.gravatar('', size);
const [provider, str] = [src.substr(0, index), src.substr(index + 1, src.length)];
if (!providers[provider] || !str) return providers.gravatar('', size);