@@ -50,6 +50,18 @@ test('lowercases slug in rewritten URL', () => {
5050 expect ( result ?. pathname ) . toBe ( '/mdn/content/main/files/en-us/web/api/htmlelement/index.md' )
5151} )
5252
53+ test ( 'rewrites locale-less docs URL to mdn/content repo' , ( ) => {
54+ const rule = mdn ( )
55+ const url = new URL ( 'https://developer.mozilla.org/docs/Web/API/Fetch_API/Using_Fetch' )
56+ const pattern = rule . patterns [ 1 ]
57+ assert ( pattern instanceof URLPattern )
58+ const match = pattern . exec ( url ) !
59+ const result = rule . rewrite ! ( url , match )
60+ expect ( result ?. href ) . toBe (
61+ 'https://raw.githubusercontent.com/mdn/content/main/files/en-us/web/api/fetch_api/using_fetch/index.md' ,
62+ )
63+ } )
64+
5365// Integration test
5466
5567test ( 'extract produces expected output for Array.prototype.map' , async ( ) => {
@@ -66,6 +78,24 @@ test('extract produces expected output for Array.prototype.map', async () => {
6678 expect ( result . meta . title ) . toBe ( 'Array.prototype.map()' )
6779} )
6880
81+ test ( 'locale-less docs URL uses markdown source so code fence info stays on the fence' , async ( ) => {
82+ const md = create ( {
83+ rules : [ mdn ( ) ] ,
84+ fetch : async ( input ) => {
85+ const url = input instanceof URL ? input . href : typeof input === 'string' ? input : input . url
86+ expect ( url ) . toBe (
87+ 'https://raw.githubusercontent.com/mdn/content/main/files/en-us/web/api/fetch_api/using_fetch/index.md' ,
88+ )
89+ return new Response ( '---\ntitle: Test\n---\n\n```js\nconst x = 1\n```' , { status : 200 } )
90+ } ,
91+ } )
92+ const result = await md . fetch ( 'https://developer.mozilla.org/docs/Web/API/Fetch_API/Using_Fetch' )
93+ expect ( result . ok ) . toBe ( true )
94+ if ( ! result . ok ) return
95+ expect ( result . content ) . toContain ( '```js\nconst x = 1' )
96+ expect ( result . content ) . not . toContain ( '\njs\n\n```' )
97+ } )
98+
6999// Extract behavior tests
70100
71101test ( 'converts jsxref macros to linked inline code' , async ( ) => {
0 commit comments