Skip to content

Commit

Permalink
mdn: bcd not loaded from new host
Browse files Browse the repository at this point in the history
Fix #890
  • Loading branch information
myfreeer committed Jul 16, 2023
1 parent 08c725f commit c1c15e6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/mdn/process-url/redirect-download-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ export const redirectDownloadLink = (res: Resource): Resource => {
.toString();
return res;
}
// https://github.com/mdn/yari/commit/6e9fb23dad1571a463e06db7e280e6479b2582bd
// https://github.com/website-local/mdn-local/issues/890
// 20230716
if (path.startsWith('/bcd/api/v0/')) {
res.downloadLink = uri.search('')
.host('bcd.developer.mozilla.org')
.toString();
return res;
}
}
return res;
};
16 changes: 16 additions & 0 deletions test/mdn/process-url/redirect-download-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,20 @@ describe('redirect-download-link', function () {
expect(resource.downloadLink).toBe(url);
}
});

// https://github.com/mdn/yari/commit/6e9fb23dad1571a463e06db7e280e6479b2582bd
// https://github.com/website-local/mdn-local/issues/890
// 20230716
test('bcd.developer.mozilla.org', () => {
const urls = [
'https://developer.mozilla.org/bcd/api/v0/current/css.properties.grid.json'
];
for (const url of urls) {
const resource = res(url);
redirectDownloadLink(resource);
expect(resource.uri?.host()).toBe('developer.mozilla.org');
expect(resource.downloadLink).toBe('https://bcd.developer.mozilla.org/bcd/api/v0/current/css.properties.grid.json');
}
});

});

0 comments on commit c1c15e6

Please sign in to comment.