File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
dotcom-rendering/src/server Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -647,9 +647,9 @@ <h2>Test Articles By Element (Missing)</h2>
647
647
const getPageType = ( url ) => {
648
648
// All interactive pages include this in the URL
649
649
if ( url . includes ( '/ng-interactive/' ) ) return 'Interactive' ;
650
- // We're looking for the date string, e.g /2022/jul/30
651
650
else if (
652
- url . match ( / ( \/ \d { 4 } \/ [ a - z ] { 3 } \/ \d { 2 } \/ | \/ [ a - z - ] + \/ \d + $ ) / )
651
+ url . match ( / \/ \d { 4 } \/ [ a - z ] { 3 } \/ \d { 2 } \/ / ) || // Standard article date format e.g /2022/jul/30
652
+ url . match ( / \/ [ a - z - ] + \/ \d + $ / ) // Crossword format e.g /crosswords/quick/17117
653
653
)
654
654
return 'Article' ;
655
655
// This is imperfect, but covers some cases of tag pages, consider expanding in the future
Original file line number Diff line number Diff line change @@ -22,7 +22,9 @@ import {
22
22
} from './handler.front.web' ;
23
23
24
24
/** article URLs contain a part that looks like “2022/nov/25” */
25
- const ARTICLE_URL = / ( \/ \d { 4 } \/ [ a - z ] { 3 } \/ \d { 2 } \/ | \/ [ a - z - ] + \/ \d + $ ) / ;
25
+ const ARTICLE_URL = / ( \/ \d { 4 } \/ [ a - z ] { 3 } \/ \d { 2 } \/ ) / ;
26
+ /** Crossword URLs end with e.g /crosswords/quick/17117 */
27
+ const CROSSWORD_URL = / ( \/ [ a - z - ] + \/ \d + $ ) / ;
26
28
/** fronts are a series of lowercase strings, dashes and forward slashes */
27
29
const FRONT_URL = / ^ \/ [ a - z - / ] + (?< ! \. c s s ) $ / ;
28
30
/** This is imperfect, but covers *some* cases of tag pages, consider expanding in the future */
@@ -98,7 +100,10 @@ export const devServer = (): Handler => {
98
100
// Do not redirect assets urls
99
101
if ( req . url . match ( ASSETS_URL ) ) return next ( ) ;
100
102
101
- if ( req . url . match ( ARTICLE_URL ) ) {
103
+ if (
104
+ req . url . match ( ARTICLE_URL ) ??
105
+ req . url . match ( CROSSWORD_URL )
106
+ ) {
102
107
const url = new URL (
103
108
req . url ,
104
109
'https://www.theguardian.com/' ,
You can’t perform that action at this time.
0 commit comments