Commit ad014c7 1 parent f05b053 commit ad014c7 Copy full SHA for ad014c7
File tree 3 files changed +10
-9
lines changed
3 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -215,15 +215,15 @@ export class AngularServerApp {
215
215
let html = await assets . getIndexServerHtml ( ) ;
216
216
// Skip extra microtask if there are no pre hooks.
217
217
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 } ) ;
219
219
}
220
220
221
221
this . boostrap ??= await bootstrap ( ) ;
222
222
223
223
html = await renderAngular (
224
224
html ,
225
225
this . boostrap ,
226
- new URL ( request . url ) ,
226
+ url ,
227
227
platformProviders ,
228
228
SERVER_CONTEXT_VALUE [ renderMode ] ,
229
229
) ;
Original file line number Diff line number Diff line change 7
7
*/
8
8
9
9
/**
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 .
12
12
*
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.
15
15
*/
16
- type HtmlTransformHandler = ( ctx : { html : string } ) => string | Promise < string > ;
16
+ type HtmlTransformHandler = ( ctx : { url : URL ; html : string } ) => string | Promise < string > ;
17
17
18
18
/**
19
19
* 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';
10
10
11
11
describe ( 'Hooks' , ( ) => {
12
12
let hooks : Hooks & { run : Function } ;
13
+ const url = new URL ( 'http://example.com/' ) ;
13
14
14
15
beforeEach ( ( ) => {
15
16
hooks = new Hooks ( ) as Hooks & { run : Function } ;
@@ -33,12 +34,12 @@ describe('Hooks', () => {
33
34
hooks . on ( 'html:transform:pre' , ( { html } ) => html + '1' ) ;
34
35
hooks . on ( 'html:transform:pre' , ( { html } ) => html + '2' ) ;
35
36
36
- const result = await hooks . run ( 'html:transform:pre' , { html : 'start' } ) ;
37
+ const result = await hooks . run ( 'html:transform:pre' , { html : 'start' , url } ) ;
37
38
expect ( result ) . toBe ( 'start12' ) ;
38
39
} ) ;
39
40
40
41
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 } ) ;
42
43
expect ( result ) . toBe ( 'start' ) ;
43
44
} ) ;
44
45
You can’t perform that action at this time.
0 commit comments