This commit is contained in:
the-djmaze 2023-02-12 01:02:55 +01:00
parent 98d686bc14
commit 6237a3691b
3 changed files with 5 additions and 5 deletions

View file

@ -302,7 +302,7 @@ export class EmailModel extends AbstractModel {
* @returns {string}
*/
hash(withoutName = false) {
return '#' + (withoutName ? '' : this.name) + '#' + this.email + '#';
return '#' + (withoutName ? '' : this.name) + '#' + (this.email || this.name) + '#';
}
/**
@ -328,8 +328,8 @@ export class EmailModel extends AbstractModel {
* @returns {string}
*/
toLine(friendlyView, wrapWithLink) {
let result = this.email,
name = this.name,
let name = this.name,
result = this.email || name,
toLink = text =>
'<a href="mailto:'
+ encodeHtml(result) + (name ? '?to=' + encodeURIComponent('"' + name + '" <' + result + '>') : '')

View file

@ -28,7 +28,7 @@ class Email implements \JsonSerializable
*/
function __construct(string $sEmail, string $sDisplayName = '')
{
if (!\strlen(\trim($sEmail))) {
if (!\strlen(\trim($sEmail)) && !\strlen(\trim($sDisplayName))) {
throw new \InvalidArgumentException;
}

View file

@ -81,7 +81,7 @@ class HeaderCollection extends \MailSo\Base\Collection
if (\strlen($sValue)) {
$oResult = new EmailCollection($sValue);
}
return $oResult && $oResult->count() ? $oResult : null;
return $oResult;
}
public function ParametersByName(string $sHeaderName) : ?ParameterCollection