Skip to content

Commit

Permalink
Merge branch 'latest' into WSTEAM1-1367
Browse files Browse the repository at this point in the history
  • Loading branch information
shayneahchoon authored Oct 21, 2024
2 parents 84a4db1 + 76b8528 commit 4a15af4
Show file tree
Hide file tree
Showing 16 changed files with 113 additions and 39 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .yarn/cache/fsevents-patch-6b67494872-10.zip
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"compression": "1.7.4",
"core-js": "3.37.1",
"dotenv": "16.4.5",
"express": "4.20.0",
"express": "4.21.1",
"express-static-gzip": "2.1.7",
"helmet": "7.1.0",
"helmet-csp": "4.0.0",
Expand Down
4 changes: 4 additions & 0 deletions src/app/lib/config/services/somali.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ export const service: DefaultServiceConfig = {
title: 'War',
url: '/somali',
},
{
title: 'Doorashada Mareykanka 2024',
url: '/somali/topics/cv2g4v31x97t',
},
{
title: 'Ganacsi',
url: '/somali/topics/c2dwqd32v4yt',
Expand Down
4 changes: 4 additions & 0 deletions src/app/lib/config/services/urdu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ export const service: DefaultServiceConfig = {
title: 'صفحۂ اول',
url: '/urdu',
},
{
title: 'امریکی صدارتی انتخاب 2024',
url: '/urdu/topics/c0w3wed04e3t',
},
{
title: 'پاکستان',
url: '/urdu/topics/cjgn7n9zzq7t',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,48 +215,55 @@ exports[`AMP Feature Index page Header Navigation link should match text and url
`;

exports[`AMP Feature Index page Header Navigation link should match text and url 2`] = `
{
"text": "امریکی صدارتی انتخاب 2024",
"url": "/urdu/topics/c0w3wed04e3t",
}
`;

exports[`AMP Feature Index page Header Navigation link should match text and url 3`] = `
{
"text": "پاکستان",
"url": "/urdu/topics/cjgn7n9zzq7t",
}
`;

exports[`AMP Feature Index page Header Navigation link should match text and url 3`] = `
exports[`AMP Feature Index page Header Navigation link should match text and url 4`] = `
{
"text": "آس پاس",
"url": "/urdu/topics/cl8l9mveql2t",
}
`;

exports[`AMP Feature Index page Header Navigation link should match text and url 4`] = `
exports[`AMP Feature Index page Header Navigation link should match text and url 5`] = `
{
"text": "ورلڈ",
"url": "/urdu/topics/cw57v2pmll9t",
}
`;

exports[`AMP Feature Index page Header Navigation link should match text and url 5`] = `
exports[`AMP Feature Index page Header Navigation link should match text and url 6`] = `
{
"text": "کھیل",
"url": "/urdu/topics/c340q0p2585t",
}
`;

exports[`AMP Feature Index page Header Navigation link should match text and url 6`] = `
exports[`AMP Feature Index page Header Navigation link should match text and url 7`] = `
{
"text": "فن فنکار",
"url": "/urdu/topics/ckdxnx900n5t",
}
`;

exports[`AMP Feature Index page Header Navigation link should match text and url 7`] = `
exports[`AMP Feature Index page Header Navigation link should match text and url 8`] = `
{
"text": "سائنس",
"url": "/urdu/topics/c40379e2ymxt",
}
`;

exports[`AMP Feature Index page Header Navigation link should match text and url 8`] = `
exports[`AMP Feature Index page Header Navigation link should match text and url 9`] = `
{
"text": "ویڈیو",
"url": "/urdu/topics/c1e0mzr3r2yt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,48 +74,55 @@ exports[`Canonical Feature Index page Header Navigation link should match text a
`;

exports[`Canonical Feature Index page Header Navigation link should match text and url 2`] = `
{
"text": "امریکی صدارتی انتخاب 2024",
"url": "/urdu/topics/c0w3wed04e3t",
}
`;

exports[`Canonical Feature Index page Header Navigation link should match text and url 3`] = `
{
"text": "پاکستان",
"url": "/urdu/topics/cjgn7n9zzq7t",
}
`;

exports[`Canonical Feature Index page Header Navigation link should match text and url 3`] = `
exports[`Canonical Feature Index page Header Navigation link should match text and url 4`] = `
{
"text": "آس پاس",
"url": "/urdu/topics/cl8l9mveql2t",
}
`;

exports[`Canonical Feature Index page Header Navigation link should match text and url 4`] = `
exports[`Canonical Feature Index page Header Navigation link should match text and url 5`] = `
{
"text": "ورلڈ",
"url": "/urdu/topics/cw57v2pmll9t",
}
`;

exports[`Canonical Feature Index page Header Navigation link should match text and url 5`] = `
exports[`Canonical Feature Index page Header Navigation link should match text and url 6`] = `
{
"text": "کھیل",
"url": "/urdu/topics/c340q0p2585t",
}
`;

exports[`Canonical Feature Index page Header Navigation link should match text and url 6`] = `
exports[`Canonical Feature Index page Header Navigation link should match text and url 7`] = `
{
"text": "فن فنکار",
"url": "/urdu/topics/ckdxnx900n5t",
}
`;

exports[`Canonical Feature Index page Header Navigation link should match text and url 7`] = `
exports[`Canonical Feature Index page Header Navigation link should match text and url 8`] = `
{
"text": "سائنس",
"url": "/urdu/topics/c40379e2ymxt",
}
`;

exports[`Canonical Feature Index page Header Navigation link should match text and url 8`] = `
exports[`Canonical Feature Index page Header Navigation link should match text and url 9`] = `
{
"text": "ویڈیو",
"url": "/urdu/topics/c1e0mzr3r2yt",
Expand Down
28 changes: 22 additions & 6 deletions src/server/Document/Renderers/litePageTransforms/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ describe('litePageTransforms', () => {
it('should append .lite suffix to valid hrefs', () => {
const html = `
<a href="https://www.bbc.com/news">News</a>
<a href="https://www.bbc.com/serbian/lat">News</a>
<a href="https://www.bbc.com/mundo">News</a>
<a href="https://www.bbcrussian.com/news">News</a>
<a href="/news">News</a>
`;
Expand All @@ -13,31 +15,45 @@ describe('litePageTransforms', () => {

expect(modifiedHtml).toEqual(`
<a href="https://www.bbc.com/news.lite">News</a>
<a href="https://www.bbc.com/serbian/lat.lite">News</a>
<a href="https://www.bbc.com/mundo.lite">News</a>
<a href="https://www.bbcrussian.com/news.lite">News</a>
<a href="/news.lite">News</a>
`);
});

it('should not append .lite suffix to invalid hrefs', () => {
const html = `
const originalHtml = `
<a href="https://www.bbc.co.uk/news">News</a>
<a href="https://www.bbc.com/news.lite">News</a>
<a href="https://www.bbc.com/news.amp">News</a>
<a href="#news">News</a>
<a href="mailto:[email protected]">News</a>
`;

const modifiedHtml = litePageTransforms(html);
const modifiedHtml = litePageTransforms(originalHtml);

expect(modifiedHtml).toEqual(originalHtml);
});

expect(modifiedHtml).toEqual(html);
it('should not append .lite suffix to an invalid "service"', () => {
const originalHtml = `
<a href="https://www.bbc.co.uk/future">Future</a>
<a href="https://www.bbc.com/food">Food</a>
<a href="https://www.bbc.com/weather">Weather</a>
`;

const modifiedHtml = litePageTransforms(originalHtml);

expect(modifiedHtml).toEqual(originalHtml);
});

it('should not append .lite suffix when no anchor tags are present', () => {
const html = '<p>I am a paragraph</p>';
const originalHtml = '<p>I am a paragraph</p>';

const modifiedHtml = litePageTransforms(html);
const modifiedHtml = litePageTransforms(originalHtml);

expect(modifiedHtml).toEqual(html);
expect(modifiedHtml).toEqual(originalHtml);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { Services } from '#app/models/types/global';
import services from '#lib/config/services/loadableConfig';

const SERVICES = Object.keys(services) as Services[];

const VALID_DOMAINS = [
'/',
'localhost',
Expand All @@ -15,9 +20,18 @@ const isValidHref = (href: string) => {
const extension = url?.pathname?.split('.')?.pop() || '';
const startsWithHash = href?.startsWith('#');

const hasReservedRouteExtension =
RESERVED_ROUTE_EXTENSIONS.includes(extension);

const isValidDomain = VALID_DOMAINS.includes(url.hostname);
const isWsService = SERVICES.includes(
url?.pathname?.split('/')?.[1] as Services,
);

return (
VALID_DOMAINS.includes(url.hostname) &&
!RESERVED_ROUTE_EXTENSIONS.includes(extension) &&
isValidDomain &&
isWsService &&
!hasReservedRouteExtension &&
!startsWithHash
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,34 @@ exports[`Canonical Send Header Navigation link should match text and url 1`] = `
`;

exports[`Canonical Send Header Navigation link should match text and url 2`] = `
{
"text": "Doorashada Mareykanka 2024",
"url": "/somali/topics/cv2g4v31x97t",
}
`;

exports[`Canonical Send Header Navigation link should match text and url 3`] = `
{
"text": "Ganacsi",
"url": "/somali/topics/c2dwqd32v4yt",
}
`;

exports[`Canonical Send Header Navigation link should match text and url 3`] = `
exports[`Canonical Send Header Navigation link should match text and url 4`] = `
{
"text": "Cayaaraha",
"url": "/somali/topics/cpzd4zj1pn2t",
}
`;

exports[`Canonical Send Header Navigation link should match text and url 4`] = `
exports[`Canonical Send Header Navigation link should match text and url 5`] = `
{
"text": "Muuqaal",
"url": "/somali/topics/c7pl4k5r9xxt",
}
`;

exports[`Canonical Send Header Navigation link should match text and url 5`] = `
exports[`Canonical Send Header Navigation link should match text and url 6`] = `
{
"text": "Barnaamijyada Idaacadda",
"url": "/somali/topics/cn6rqlrkm0pt",
Expand Down
45 changes: 30 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9629,23 +9629,23 @@ __metadata:
languageName: node
linkType: hard

"express@npm:4.20.0":
version: 4.20.0
resolution: "express@npm:4.20.0"
"express@npm:4.21.1":
version: 4.21.1
resolution: "express@npm:4.21.1"
dependencies:
accepts: "npm:~1.3.8"
array-flatten: "npm:1.1.1"
body-parser: "npm:1.20.3"
content-disposition: "npm:0.5.4"
content-type: "npm:~1.0.4"
cookie: "npm:0.6.0"
cookie: "npm:0.7.1"
cookie-signature: "npm:1.0.6"
debug: "npm:2.6.9"
depd: "npm:2.0.0"
encodeurl: "npm:~2.0.0"
escape-html: "npm:~1.0.3"
etag: "npm:~1.8.1"
finalhandler: "npm:1.2.0"
finalhandler: "npm:1.3.1"
fresh: "npm:0.5.2"
http-errors: "npm:2.0.0"
merge-descriptors: "npm:1.0.3"
Expand All @@ -9654,17 +9654,17 @@ __metadata:
parseurl: "npm:~1.3.3"
path-to-regexp: "npm:0.1.10"
proxy-addr: "npm:~2.0.7"
qs: "npm:6.11.0"
qs: "npm:6.13.0"
range-parser: "npm:~1.2.1"
safe-buffer: "npm:5.2.1"
send: "npm:0.19.0"
serve-static: "npm:1.16.0"
serve-static: "npm:1.16.2"
setprototypeof: "npm:1.2.0"
statuses: "npm:2.0.1"
type-is: "npm:~1.6.18"
utils-merge: "npm:1.0.1"
vary: "npm:~1.1.2"
checksum: 10/4131f566cf8f6d1611475d5ff5d0dbc5c628ad8b525aa2aa2b3da9a23a041efcce09ede10b8a31315b0258ac4e53208a009fd7669ee1eb385936a0d54adb3cde
checksum: 10/5d4a36dd03c1d1cce93172e9b185b5cd13a978d29ee03adc51cd278be7b4a514ae2b63e2fdaec0c00fdc95c6cfb396d9dd1da147917ffd337d6cd0778e08c9bc
languageName: node
linkType: hard

Expand Down Expand Up @@ -9926,6 +9926,21 @@ __metadata:
languageName: node
linkType: hard

"finalhandler@npm:1.3.1":
version: 1.3.1
resolution: "finalhandler@npm:1.3.1"
dependencies:
debug: "npm:2.6.9"
encodeurl: "npm:~2.0.0"
escape-html: "npm:~1.0.3"
on-finished: "npm:2.4.1"
parseurl: "npm:~1.3.3"
statuses: "npm:2.0.1"
unpipe: "npm:~1.0.0"
checksum: 10/4babe72969b7373b5842bc9f75c3a641a4d0f8eb53af6b89fa714d4460ce03fb92b28de751d12ba415e96e7e02870c436d67412120555e2b382640535697305b
languageName: node
linkType: hard

"find-cache-dir@npm:^2.0.0":
version: 2.1.0
resolution: "find-cache-dir@npm:2.1.0"
Expand Down Expand Up @@ -15846,15 +15861,15 @@ __metadata:
languageName: node
linkType: hard

"serve-static@npm:1.16.0":
version: 1.16.0
resolution: "serve-static@npm:1.16.0"
"serve-static@npm:1.16.2":
version: 1.16.2
resolution: "serve-static@npm:1.16.2"
dependencies:
encodeurl: "npm:~1.0.2"
encodeurl: "npm:~2.0.0"
escape-html: "npm:~1.0.3"
parseurl: "npm:~1.3.3"
send: "npm:0.18.0"
checksum: 10/29a01f67e8c64a359d49dd0c46bc95bb4aa99781f97845dccbf0c8cd0284c5fd79ad7fb9433a36fac4b6c58b577d3eab314a379142412413b8b5cd73be3cd551
send: "npm:0.19.0"
checksum: 10/7fa9d9c68090f6289976b34fc13c50ac8cd7f16ae6bce08d16459300f7fc61fbc2d7ebfa02884c073ec9d6ab9e7e704c89561882bbe338e99fcacb2912fde737
languageName: node
linkType: hard

Expand Down Expand Up @@ -16089,7 +16104,7 @@ __metadata:
eslint-plugin-prettier: "npm:5.2.1"
eslint-plugin-react: "npm:7.35.0"
eslint-plugin-react-hooks: "npm:4.6.2"
express: "npm:4.20.0"
express: "npm:4.21.1"
express-static-gzip: "npm:2.1.7"
glob: "npm:11.0.0"
helmet: "npm:7.1.0"
Expand Down

0 comments on commit 4a15af4

Please sign in to comment.