Skip to content

Commit

Permalink
News web now has a generator meta tag for all outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
drzax committed Oct 31, 2022
1 parent 186e398 commit 60ab8cc
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ const isSelectable = (selector: string): boolean =>
!!document.querySelector(selector);
const isGeneratedBy = (generatorName: string): boolean =>
isSelectable(`[name="generator"][content="${generatorName}"]`);
const hasIconFrom = (slug: string): boolean =>
isSelectable(`[rel*="icon"][href^="/${slug}/"]`);
const memoize = <T>(fn: (cache?: boolean) => T) => {
let cached: T;
return (cache: boolean = true) =>
Expand All @@ -96,14 +94,10 @@ const memoize = <T>(fn: (cache?: boolean) => T) => {
// <meta name="HandheldFriendly"> tag.
// * Phase 2 and most Presentation Layer applications have a
// <meta name="generator"> tag with a distinct "content" property value.
// * Presentation Layer's News Web application doesn't have a
// <meta name="generator"> tag with a distinct "content" property value
// when rendering ABC News App articles, so we look for an icon <link>
// with a distinct asset path.
// * Checks are made in order of likelihood, to save unnecessary DOM reads
export const getApplication = memoize(
function _getApplication(): APPLICATIONS | null {
return hasIconFrom('news-web')
return isGeneratedBy('PL NEWS WEB')
? APPLICATIONS.PLN
: isSelectable('[name="HandheldFriendly"]')
? APPLICATIONS.P1M
Expand Down

0 comments on commit 60ab8cc

Please sign in to comment.