Skip to content

Commit

Permalink
Merge branch 'latest' into WSTEAMA-1407-uzbek-homepage-script-switch
Browse files Browse the repository at this point in the history
  • Loading branch information
karinathomasbbc authored Oct 23, 2024
2 parents c94b93c + c067a6b commit 75833fe
Show file tree
Hide file tree
Showing 284 changed files with 1,232 additions and 1,226 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"./cypress/**/*.*"
],
"resolutions": {
"@babel/runtime": "7.25.7",
"@babel/runtime": "7.25.9",
"@optimizely/js-sdk-utils": "0.4.0",
"uuid": "3.4.0",
"[email protected]": "patch:winston@npm:3.8.2#.yarn/patches/winston-npm-3.8.2-2035e9cac4.patch",
Expand Down Expand Up @@ -130,18 +130,18 @@
"winston": "patch:[email protected]#./patches/winston-file-descriptor.patch"
},
"devDependencies": {
"@babel/core": "7.25.8",
"@babel/eslint-parser": "7.25.8",
"@babel/plugin-proposal-export-default-from": "7.25.8",
"@babel/core": "7.25.9",
"@babel/eslint-parser": "7.25.9",
"@babel/plugin-proposal-export-default-from": "7.25.9",
"@babel/plugin-proposal-object-rest-spread": "7.20.7",
"@babel/plugin-proposal-throw-expressions": "7.25.8",
"@babel/plugin-proposal-throw-expressions": "7.25.9",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/plugin-transform-runtime": "7.25.7",
"@babel/plugin-transform-runtime": "7.25.9",
"@babel/polyfill": "7.12.1",
"@babel/preset-env": "7.25.8",
"@babel/preset-react": "7.25.7",
"@babel/preset-typescript": "7.25.7",
"@babel/runtime": "7.25.7",
"@babel/preset-env": "7.25.9",
"@babel/preset-react": "7.25.9",
"@babel/preset-typescript": "7.25.9",
"@babel/runtime": "7.25.9",
"@cypress/webpack-preprocessor": "6.0.2",
"@emotion/babel-plugin": "11.11.0",
"@emotion/babel-preset-css-prop": "11.11.0",
Expand All @@ -160,19 +160,19 @@
"@next/swc-linux-x64-gnu": "14.2.14",
"@next/swc-win32-arm64-msvc": "14.2.14",
"@next/swc-win32-x64-msvc": "14.2.14",
"@storybook/addon-a11y": "8.2.9",
"@storybook/addon-backgrounds": "8.2.9",
"@storybook/addon-controls": "8.2.9",
"@storybook/addon-docs": "8.2.9",
"@storybook/addon-toolbars": "8.2.9",
"@storybook/addon-viewport": "8.2.9",
"@storybook/blocks": "8.2.9",
"@storybook/builder-webpack5": "8.2.9",
"@storybook/cli": "8.2.9",
"@storybook/core-common": "8.2.9",
"@storybook/react": "8.2.9",
"@storybook/react-webpack5": "8.2.9",
"@storybook/theming": "8.2.9",
"@storybook/addon-a11y": "8.3.6",
"@storybook/addon-backgrounds": "8.3.6",
"@storybook/addon-controls": "8.3.6",
"@storybook/addon-docs": "8.3.6",
"@storybook/addon-toolbars": "8.3.6",
"@storybook/addon-viewport": "8.3.6",
"@storybook/blocks": "8.3.6",
"@storybook/builder-webpack5": "8.3.6",
"@storybook/cli": "8.3.6",
"@storybook/core-common": "8.3.6",
"@storybook/react": "8.3.6",
"@storybook/react-webpack5": "8.3.6",
"@storybook/theming": "8.3.6",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.5.0",
"@testing-library/react": "15.0.7",
Expand Down Expand Up @@ -214,7 +214,7 @@
"eslint-config-airbnb": "18.2.1",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-alias": "1.1.2",
"eslint-plugin-cypress": "3.5.0",
"eslint-plugin-cypress": "4.0.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-json": "4.0.0",
"eslint-plugin-jsx-a11y": "6.10.0",
Expand All @@ -240,7 +240,7 @@
"prettier": "3.2.5",
"retry": "0.13.1",
"start-server-nestjs-webpack-plugin": "2.2.5",
"storybook": "8.2.9",
"storybook": "8.3.6",
"stream-browserify": "3.0.0",
"strip-ansi": "7.1.0",
"supertest": "7.0.0",
Expand Down
4 changes: 4 additions & 0 deletions src/app/lib/config/services/azeri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ export const service: DefaultServiceConfig = {
title: 'Beynəlxalq',
url: '/azeri/topics/cde15l4vn02t',
},
{
title: 'COP29',
url: '/azeri/topics/cv2dz9j8ywyt',
},
],
},
};
Expand Down
24 changes: 2 additions & 22 deletions src/app/lib/config/services/serbian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ export const service: SerbianConfig = {
url: '/serbian/lat',
},
{
title: 'Ukrajina',
url: '/serbian/lat/topics/c5wzvzzz5vrt',
title: 'Američki izbori',
url: '/serbian/lat/topics/c1v8enng1npt',
},
{
title: 'Srbija',
Expand Down Expand Up @@ -503,26 +503,6 @@ export const service: SerbianConfig = {
title: 'Почетна страна',
url: '/serbian/cyr',
},
{
title: 'Украјина',
url: '/serbian/cyr/topics/cqwvxvvw9qrt',
},
{
title: 'Србија',
url: '/serbian/cyr/topics/cvjp1d3k9dvt',
},
{
title: 'Балкан',
url: '/serbian/cyr/topics/c8y9k0k2pvvt',
},
{
title: 'Свет',
url: '/serbian/cyr/topics/c3m1x951mljt',
},
{
title: 'Видео',
url: '/serbian/cyr/topics/crg7kj2ejj2t',
},
{
title: 'Најпопуларније',
url: '/serbian/cyr/popular/read',
Expand Down
20 changes: 20 additions & 0 deletions src/app/lib/config/services/tigrinya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,26 @@ export const service: DefaultServiceConfig = {
title: 'ዜና',
url: '/tigrinya',
},
{
title: 'ኤርትራ',
url: '/tigrinya/topics/c1gdqrg28zxt',
},
{
title: 'ኢትዮጵያ',
url: '/tigrinya/topics/cdr56vrknx6t',
},
{
title: 'ሱዳን',
url: '/tigrinya/topics/c5qvp11n2vzt',
},
{
title: 'ቅልውላው ማእከላይ ምብራቕ',
url: '/tigrinya/topics/c5qvp1qz3q6t',
},
{
title: 'ምርጫ ኣመሪካ',
url: '/tigrinya/topics/cxdyjg4kpxpt',
},
{
title: 'ቪድዮ',
url: '/tigrinya/topics/crldzm9n4rdt',
Expand Down
4 changes: 4 additions & 0 deletions src/app/lib/config/services/turkce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ export const service: DefaultServiceConfig = {
title: 'Orta Doğu',
url: '/turkce/topics/cg726y2qxg1t',
},
{
title: 'ABD Seçimleri',
url: '/turkce/topics/c3gyjy0vy91t',
},
{
title: 'Rusya-Ukrayna Savaşı',
url: '/turkce/topics/cy0ryl4pvx6t',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,41 +204,6 @@ exports[`AMP Home Page Header Navigation link should match text and url 1`] = `
`;

exports[`AMP Home Page Header Navigation link should match text and url 2`] = `
{
"text": "Украјина",
"url": "/serbian/cyr/topics/cqwvxvvw9qrt",
}
`;

exports[`AMP Home Page Header Navigation link should match text and url 3`] = `
{
"text": "Србија",
"url": "/serbian/cyr/topics/cvjp1d3k9dvt",
}
`;

exports[`AMP Home Page Header Navigation link should match text and url 4`] = `
{
"text": "Балкан",
"url": "/serbian/cyr/topics/c8y9k0k2pvvt",
}
`;

exports[`AMP Home Page Header Navigation link should match text and url 5`] = `
{
"text": "Свет",
"url": "/serbian/cyr/topics/c3m1x951mljt",
}
`;

exports[`AMP Home Page Header Navigation link should match text and url 6`] = `
{
"text": "Видео",
"url": "/serbian/cyr/topics/crg7kj2ejj2t",
}
`;

exports[`AMP Home Page Header Navigation link should match text and url 7`] = `
{
"text": "Најпопуларније",
"url": "/serbian/cyr/popular/read",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,41 +74,6 @@ exports[`Canonical Home Page Header Navigation link should match text and url 1`
`;

exports[`Canonical Home Page Header Navigation link should match text and url 2`] = `
{
"text": "Украјина",
"url": "/serbian/cyr/topics/cqwvxvvw9qrt",
}
`;

exports[`Canonical Home Page Header Navigation link should match text and url 3`] = `
{
"text": "Србија",
"url": "/serbian/cyr/topics/cvjp1d3k9dvt",
}
`;

exports[`Canonical Home Page Header Navigation link should match text and url 4`] = `
{
"text": "Балкан",
"url": "/serbian/cyr/topics/c8y9k0k2pvvt",
}
`;

exports[`Canonical Home Page Header Navigation link should match text and url 5`] = `
{
"text": "Свет",
"url": "/serbian/cyr/topics/c3m1x951mljt",
}
`;

exports[`Canonical Home Page Header Navigation link should match text and url 6`] = `
{
"text": "Видео",
"url": "/serbian/cyr/topics/crg7kj2ejj2t",
}
`;

exports[`Canonical Home Page Header Navigation link should match text and url 7`] = `
{
"text": "Најпопуларније",
"url": "/serbian/cyr/popular/read",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ exports[`AMP Home Page Header Navigation link should match text and url 1`] = `

exports[`AMP Home Page Header Navigation link should match text and url 2`] = `
{
"text": "Ukrajina",
"url": "/serbian/lat/topics/c5wzvzzz5vrt",
"text": "Američki izbori",
"url": "/serbian/lat/topics/c1v8enng1npt",
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ exports[`Canonical Home Page Header Navigation link should match text and url 1`

exports[`Canonical Home Page Header Navigation link should match text and url 2`] = `
{
"text": "Ukrajina",
"url": "/serbian/lat/topics/c5wzvzzz5vrt",
"text": "Američki izbori",
"url": "/serbian/lat/topics/c1v8enng1npt",
}
`;

Expand Down
15 changes: 15 additions & 0 deletions src/server/Document/Renderers/litePageTransforms/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ describe('litePageTransforms', () => {
<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="https://www.bbc.com/mundo?something=value&another=one#content">News</a>
<a href="/news">News</a>
<a href="/news?something=value&another=one#content">News</a>
`;

const modifiedHtml = litePageTransforms(html);
Expand All @@ -18,7 +20,9 @@ describe('litePageTransforms', () => {
<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="https://www.bbc.com/mundo.lite?something=value&another=one#content">News</a>
<a href="/news.lite">News</a>
<a href="/news.lite?something=value&another=one#content">News</a>
`);
});

Expand Down Expand Up @@ -55,5 +59,16 @@ describe('litePageTransforms', () => {

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

it('should not append .lite suffix when href is not present or is empty', () => {
const originalHtml = `
<a>News</a>
<a href="">News</a>
`;

const modifiedHtml = litePageTransforms(originalHtml);

expect(modifiedHtml).toEqual(originalHtml);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,37 @@ const VALID_DOMAINS = [

const RESERVED_ROUTE_EXTENSIONS = ['amp', 'app', 'lite'];

const isValidHref = (href: string) => {
const url = new URL(href, 'http://localhost');
const addLiteExtension = (href?: string) => {
if (!href) return null;

const extension = url?.pathname?.split('.')?.pop() || '';
const startsWithHash = href?.startsWith('#');
const url = new URL(href, 'http://localhost');

const hasReservedRouteExtension =
RESERVED_ROUTE_EXTENSIONS.includes(extension);
const extension = url.pathname?.split('.')?.pop() || '';

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

return (
isValidDomain &&
isWsService &&
!hasReservedRouteExtension &&
!startsWithHash
);
const hasReservedRouteExtension =
RESERVED_ROUTE_EXTENSIONS.includes(extension);

const shouldAddLiteExtension =
isValidDomain && isWsService && !hasReservedRouteExtension;

if (shouldAddLiteExtension) {
url.pathname += '.lite';

// Retain relative path if passed in 'href' starts with a forward slash
if (href.startsWith('/')) {
return `${url.pathname}${url.search}${url.hash}`;
}

// Else return the full URL
return url.toString();
}

return null;
};

export default (html: string) => {
Expand All @@ -44,10 +55,12 @@ export default (html: string) => {

anchorTags.forEach(tag => {
const href = tag?.match(/href="([^"]*)"/)?.[1];
if (href && isValidHref(href)) {
const urlWithLite = addLiteExtension(href);

if (href && urlWithLite) {
modifiedHtml = modifiedHtml.replace(
tag,
tag.replace(href, `${href}.lite`),
tag.replace(href, urlWithLite),
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ exports[`Canonical Live Header Navigation link should match text and url 1`] = `

exports[`Canonical Live Header Navigation link should match text and url 2`] = `
{
"text": "Ukrajina",
"url": "/serbian/lat/topics/c5wzvzzz5vrt",
"text": "Američki izbori",
"url": "/serbian/lat/topics/c1v8enng1npt",
}
`;

Expand Down
Loading

0 comments on commit 75833fe

Please sign in to comment.