NetNewsWire/Frameworks/RSParser/Feeds/XML/RSParsedAuthor.m
2017-12-19 13:03:05 -08:00

34 lines
668 B
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// RSParsedAuthor.m
// RSParserTests
//
// Created by Brent Simmons on 12/19/17.
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
//
#import <RSParser/NSString+RSParser.h>
#import "RSParsedAuthor.h"
@implementation RSParsedAuthor
+ (instancetype)authorWithSingleString:(NSString *)s {
// The author element in RSS is supposed to be email address — but often its a name, and sometimes a URL.
RSParsedAuthor *author = [[self alloc] init];
if ([s rsparser_contains:@"@"]) {
author.emailAddress = s;
}
else if ([s.lowercaseString hasPrefix:@"http"]) {
author.url = s;
}
else {
author.name = s;
}
return author;
}
@end