File tree Expand file tree Collapse file tree 3 files changed +10
-9
lines changed
Expand file tree Collapse file tree 3 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -215,15 +215,15 @@ export class AngularServerApp {
215215 let html = await assets . getIndexServerHtml ( ) ;
216216 // Skip extra microtask if there are no pre hooks.
217217 if ( hooks . has ( 'html:transform:pre' ) ) {
218- html = await hooks . run ( 'html:transform:pre' , { html } ) ;
218+ html = await hooks . run ( 'html:transform:pre' , { html, url } ) ;
219219 }
220220
221221 this . boostrap ??= await bootstrap ( ) ;
222222
223223 html = await renderAngular (
224224 html ,
225225 this . boostrap ,
226- new URL ( request . url ) ,
226+ url ,
227227 platformProviders ,
228228 SERVER_CONTEXT_VALUE [ renderMode ] ,
229229 ) ;
Original file line number Diff line number Diff line change 77 */
88
99/**
10- * Handler function type for HTML transformation hooks .
11- * It takes an object containing the HTML content to be modified .
10+ * Defines a handler function type for transforming HTML content .
11+ * This function receives an object with the HTML to be processed .
1212 *
13- * @param ctx - The context object containing the HTML content.
14- * @returns The modified HTML content or a promise that resolves to the modified HTML content .
13+ * @param ctx - An object containing the URL and HTML content to be transformed .
14+ * @returns The transformed HTML as a string or a promise that resolves to the transformed HTML.
1515 */
16- type HtmlTransformHandler = ( ctx : { html : string } ) => string | Promise < string > ;
16+ type HtmlTransformHandler = ( ctx : { url : URL ; html : string } ) => string | Promise < string > ;
1717
1818/**
1919 * Defines the names of available hooks for registering and triggering custom logic within the application.
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { Hooks } from '../src/hooks';
1010
1111describe ( 'Hooks' , ( ) => {
1212 let hooks : Hooks & { run : Function } ;
13+ const url = new URL ( 'http://example.com/' ) ;
1314
1415 beforeEach ( ( ) => {
1516 hooks = new Hooks ( ) as Hooks & { run : Function } ;
@@ -33,12 +34,12 @@ describe('Hooks', () => {
3334 hooks . on ( 'html:transform:pre' , ( { html } ) => html + '1' ) ;
3435 hooks . on ( 'html:transform:pre' , ( { html } ) => html + '2' ) ;
3536
36- const result = await hooks . run ( 'html:transform:pre' , { html : 'start' } ) ;
37+ const result = await hooks . run ( 'html:transform:pre' , { html : 'start' , url } ) ;
3738 expect ( result ) . toBe ( 'start12' ) ;
3839 } ) ;
3940
4041 it ( 'should return the context html if no hooks are registered' , async ( ) => {
41- const result = await hooks . run ( 'html:transform:pre' , { html : 'start' } ) ;
42+ const result = await hooks . run ( 'html:transform:pre' , { html : 'start' , url } ) ;
4243 expect ( result ) . toBe ( 'start' ) ;
4344 } ) ;
4445
You can’t perform that action at this time.
0 commit comments