@svelte-put/avatar
Advanced tools
Comparing version 1.0.10 to 1.0.11
import { SvelteComponentTyped } from "svelte"; | ||
import type { AvatarProps } from './avatar.types'; | ||
import type { AvatarSlots, GravatarOptions, UIAvatarOptions } from './avatar.types'; | ||
import type { AvatarSlots, AvatarProps } from './avatar.types'; | ||
declare const __propDef: { | ||
props: { | ||
src?: string | undefined; | ||
gravatar?: string | GravatarOptions | undefined; | ||
uiAvatar?: string | UIAvatarOptions | undefined; | ||
gravatar?: string | import("./avatar.types").GravatarOptions | undefined; | ||
uiAvatar?: string | import("./avatar.types").UIAvatarOptions | undefined; | ||
fallback?: string | undefined; | ||
@@ -10,0 +9,0 @@ size?: number | undefined; |
@@ -5,3 +5,3 @@ import type { AvatarProps } from './avatar.types'; | ||
*/ | ||
export declare function resolveAlt(alt?: string, gravatar?: AvatarProps['gravatar'], uiAvatar?: AvatarProps['uiAvatar']): string; | ||
export declare function resolveAlt(alt?: string, gravatar?: AvatarProps['gravatar'], uiAvatar?: AvatarProps['uiAvatar'], src?: string): string; | ||
/** | ||
@@ -8,0 +8,0 @@ * @internal |
@@ -14,2 +14,11 @@ import { gravatar as constructGravatarUrl, uiAvatar as constructUIAvatarUrl, } from './avatar.helpers'; | ||
} | ||
/** @internal */ | ||
function getAltFromUrl(url) { | ||
// match "name" or "email" query param from url | ||
const match = url.match(/(name|email)=([^&]+)/); | ||
if (match) { | ||
return match[2]; | ||
} | ||
return ''; | ||
} | ||
/** | ||
@@ -26,3 +35,3 @@ * @internal | ||
*/ | ||
export function resolveAlt(alt, gravatar, uiAvatar) { | ||
export function resolveAlt(alt, gravatar, uiAvatar, src) { | ||
if (alt) | ||
@@ -32,2 +41,4 @@ return alt; | ||
return gravatar.email; | ||
if (typeof gravatar === 'string' && gravatar) | ||
return gravatar; | ||
if (typeof uiAvatar === 'object' && uiAvatar.name) | ||
@@ -37,2 +48,4 @@ return uiAvatar.name; | ||
return uiAvatar; | ||
if (src) | ||
return getAltFromUrl(src); | ||
return ''; | ||
@@ -39,0 +52,0 @@ } |
{ | ||
"name": "@svelte-put/avatar", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "Component and utils for handling avatar", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24034
318