fix potential errors when fetching favicon that preven feed from being added, fix #66 by not shortening the url

This commit is contained in:
Bernhard Posselt 2013-04-15 18:49:44 +02:00
Родитель 0ed9131f3f
Коммит 34342814a0
4 изменённых файлов: 15 добавлений и 21 удалений

Просмотреть файл

@ -140,9 +140,7 @@ FeedModel, NewLoading, _ExistsError, Utils) ->
throw new _ExistsError('Exists already')
feed =
title: url.replace(
/^(?:https?:\/\/)?(?:www\.)?([a-z0-9_\-\.]+)(?:\/.*)?$/gi,
'$1')
title: url
url: url
urlHash: urlHash
folderId: parentId

Просмотреть файл

@ -896,7 +896,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
throw new _ExistsError('Exists already');
}
feed = {
title: url.replace(/^(?:https?:\/\/)?(?:www\.)?([a-z0-9_\-\.]+)(?:\/.*)?$/gi, '$1'),
title: url,
url: url,
urlHash: urlHash,
folderId: parentId,

Просмотреть файл

@ -255,28 +255,13 @@ describe 'FeedBusinessLayer', ->
feed = @FeedModel.getByUrlHash(hash)
expect(feed.title).toBe('google.de')
expect(feed.title).toBe('www.google.de')
expect(feed.url).toBe(url)
expect(feed.urlHash).toBe(hash)
expect(feed.folderId).toBe(0)
expect(feed.unreadCount).toBe(0)
expect(@imagePath).toHaveBeenCalledWith('core', 'loading.gif')
it 'should transform urls correctly', =>
urls = [
'www.google.de'
'www.google.de/'
'google.de'
'http://google.de'
'http://www.google.de/'
]
for url in urls
@FeedModel.clear()
@FeedBusinessLayer.create(url)
hash = hex_md5(url)
feed = @FeedModel.getByUrlHash(hash)
expect(feed.title).toBe('google.de')
it 'should make a create feed request', =>
@persistence.createFeed = jasmine.createSpy('add feed')

Просмотреть файл

@ -204,7 +204,18 @@ class FeedFetcher implements IFeedFetcher {
// try the /favicon.ico as a last resort
$parseUrl = parse_url($url);
$baseFavicon = $parseUrl['scheme'] . '://' . $parseUrl['host'] . '/favicon.ico';
if (!array_key_exists('scheme', $parseUrl)){
$scheme = 'http';
} else {
$scheme = $parseUrl['scheme'];
}
if(!array_key_exists('host', $parseUrl)){
error_log($url);
return null;
}
$baseFavicon = $scheme . '://' . $parseUrl['host'] . '/favicon.ico';
if($this->isValidFavIcon($baseFavicon)){
return $baseFavicon;
}