Skip to content

Commit

Permalink
mdn: update favicon links
Browse files Browse the repository at this point in the history
Close #211
  • Loading branch information
myfreeer committed Jan 10, 2021
1 parent 51677a0 commit 1784977
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
21 changes: 12 additions & 9 deletions src/mdn/process-url/redirect-path.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export const mdnRedirectPath = (locale: string) : Record<string, string> => ({
// https://github.com/myfreeer/mdn-local/issues/34
'/media/redesign/img/favicon32.png': '/static/img/favicon32.png',
// https://github.com/mdn/yari/pull/39
// https://github.com/website-local/mdn-local/issues/211
'/media/redesign/img/favicon32.png': '/favicon.ico',
// https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/Places/Using_the_Places_keywords_AP
[`/${locale}/docs/Bookmark_Keywords`]:
`/${locale}/docs/Archive/Mozilla/Bookmark_keywords`,
Expand Down Expand Up @@ -640,22 +642,23 @@ export const mdnLocaleRedirectPath = (locale: string): Record<string, string> =>
};

export const hardCodedRedirectUrl: Record<string, string> = {
// https://github.com/mdn/yari/pull/39
'http://w3c.org/2008/site/images/favicon.ico':
'https://developer.mozilla.org/static/img/favicon32.png',
'https://developer.mozilla.org/favicon.ico',
'https://w3c.org/2008/site/images/favicon.ico':
'https://developer.mozilla.org/static/img/favicon32.png',
'https://developer.mozilla.org/favicon.ico',
'https://mozorg.cdn.mozilla.net/media/img/favicon.ico':
'https://developer.mozilla.org/static/img/favicon32.png',
'https://developer.mozilla.org/favicon.ico',
'http://mozorg.cdn.mozilla.net/media/img/favicon.ico':
'https://developer.mozilla.org/static/img/favicon32.png',
'https://developer.mozilla.org/favicon.ico',
'http://www.mozilla.org/favicon.ico':
'https://developer.mozilla.org/static/img/favicon32.png',
'https://developer.mozilla.org/favicon.ico',
'https://www.mozilla.org/favicon.ico':
'https://developer.mozilla.org/static/img/favicon32.png',
'https://developer.mozilla.org/favicon.ico',
'https://developer.cdn.mozilla.net/media/redesign/img/favicon32.png':
'https://developer.mozilla.org/static/img/favicon32.png',
'https://developer.mozilla.org/favicon.ico',
'http://developer.cdn.mozilla.net/media/redesign/img/favicon32.png':
'https://developer.mozilla.org/static/img/favicon32.png',
'https://developer.mozilla.org/favicon.ico',
// just an alternative, not original pic
'https://i.picsum.photos/id/1080/6858/4574.jpg':
'https://developer.mozilla.org/files/16869/new-york-skyline-4by3.jpg',
Expand Down
4 changes: 3 additions & 1 deletion src/mdn/process-url/skip-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ export const skipProcess = (
return;
}
// https://github.com/myfreeer/mdn-local/issues/34
// https://github.com/mdn/yari/pull/39
// https://github.com/website-local/mdn-local/issues/211
if (remoteFavicon.has(url)) {
return 'https://developer.mozilla.org/static/img/favicon32.png';
return 'https://developer.mozilla.org/favicon.ico';
}
// https:\\google.com
// from https://developer.mozilla.org/en-US/docs/Learn/Server-side/First_steps/Introduction
Expand Down
10 changes: 6 additions & 4 deletions test/mdn/process-url/redirect-url.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,19 +245,21 @@ describe('redirect-url', function () {
});

// https://github.com/myfreeer/mdn-local/issues/34
// https://github.com/mdn/yari/pull/39
// https://github.com/website-local/mdn-local/issues/211
test('redirect unexpected favicon #34', () => {
expect(redirectUrl('https://developer.cdn.mozilla.net/media/redesign/img/favicon32.png',
null, null, opt('zh-CN')))
.toBe('https://developer.mozilla.org/static/img/favicon32.png');
.toBe('https://developer.mozilla.org/favicon.ico');
expect(redirectUrl('http://www.mozilla.org/favicon.ico',
null, null, opt('zh-CN')))
.toBe('https://developer.mozilla.org/static/img/favicon32.png');
.toBe('https://developer.mozilla.org/favicon.ico');
expect(redirectUrl('https://mozorg.cdn.mozilla.net/media/img/favicon.ico',
null, null, opt('zh-CN')))
.toBe('https://developer.mozilla.org/static/img/favicon32.png');
.toBe('https://developer.mozilla.org/favicon.ico');
expect(redirectUrl('http://w3c.org/2008/site/images/favicon.ico',
null, null, opt('zh-CN')))
.toBe('https://developer.mozilla.org/static/img/favicon32.png');
.toBe('https://developer.mozilla.org/favicon.ico');
});

// https://github.com/myfreeer/mdn-local/issues/38
Expand Down
4 changes: 3 additions & 1 deletion test/mdn/process-url/skip-process.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ describe('skip-process', function () {
});

// https://github.com/myfreeer/mdn-local/issues/34
// https://github.com/mdn/yari/pull/39
// https://github.com/website-local/mdn-local/issues/211
test('keep remote favicon #34', () => {
expect(skipProcess('http://www.mozilla.org/favicon.ico', null, null))
.toBe('https://developer.mozilla.org/static/img/favicon32.png');
.toBe('https://developer.mozilla.org/favicon.ico');
});

test('skip incorrectly-parsed url', () => {
Expand Down

0 comments on commit 1784977

Please sign in to comment.