@@ -10,6 +10,15 @@ const constructPayload = require('../lib/construct-payload');
10
10
function createApp ( options , existingPayload = { startedDateTime : new Date ( ) } ) {
11
11
const app = express ( ) ;
12
12
app . use ( bodyParser . json ( ) ) ;
13
+
14
+ const router = express . Router ( ) ;
15
+
16
+ router . post ( '/a' , ( req , res ) =>
17
+ res . json ( constructPayload ( req , res , ( ) => { } , options , existingPayload ) ) ,
18
+ ) ;
19
+
20
+ app . use ( '/test-base-path' , router ) ;
21
+
13
22
app . post ( '/*' , ( req , res ) => {
14
23
res . json ( constructPayload ( req , res , ( ) => { } , options , existingPayload ) ) ;
15
24
} ) ;
@@ -60,6 +69,15 @@ describe('constructPayload()', () => {
60
69
assert ( body . request . log . entries [ 0 ] . pageref . match ( / h t t p : \/ \/ 1 2 7 .0 .0 .1 : \d + \/ \* / ) ) ;
61
70
} ) ) ;
62
71
72
+ it ( '#pageref baseurl should be included as well' , ( ) =>
73
+ request ( createApp ( { } ) )
74
+ . post ( '/test-base-path/a' )
75
+ . expect ( ( { body } ) => {
76
+ assert (
77
+ body . request . log . entries [ 0 ] . pageref . match ( / h t t p : \/ \/ 1 2 7 .0 .0 .1 : \d + \/ t e s t - b a s e - p a t h \/ a / ) ,
78
+ ) ;
79
+ } ) ) ;
80
+
63
81
it ( '#startedDateTime' , ( ) => {
64
82
const startedDateTime = new Date ( ) ;
65
83
0 commit comments