Skip to content

Commit f54c08a

Browse files
authored
Merge pull request #69 from vivki/main
add js_periodic to parse
2 parents 656013d + 957cbd6 commit f54c08a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

analyze.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,6 +2186,10 @@ var directives = map[string][]uint{
21862186
ngxHTTPMainConf | ngxHTTPSrvConf | ngxHTTPLocConf | ngxConfTake1,
21872187
ngxStreamMainConf | ngxStreamSrvConf | ngxConfTake1,
21882188
},
2189+
"js_periodic": {
2190+
ngxHTTPLocConf | ngxConfAny,
2191+
ngxStreamSrvConf | ngxConfAny,
2192+
},
21892193
"js_preload_object": {
21902194
ngxHTTPMainConf | ngxHTTPSrvConf | ngxHTTPLocConf | ngxConfTake13,
21912195
ngxStreamMainConf | ngxStreamSrvConf | ngxConfTake13,

analyze_test.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,40 @@ func TestAnalyze_njs(t *testing.T) {
225225
blockCtx{"http", "server", "if"},
226226
true,
227227
},
228+
"js_periodic ok in http": {
229+
&Directive{
230+
Directive: "js_periodic",
231+
Args: []string{"function"},
232+
Line: 5,
233+
},
234+
blockCtx{"http", "location"},
235+
false,
236+
},
237+
"js_periodic not ok in http": {
238+
&Directive{
239+
Directive: "js_periodic",
240+
Args: []string{"function"},
241+
Line: 5,
242+
},
243+
blockCtx{"http", "location", "if"},
244+
true,
245+
},
246+
"js_periodic ok in stream": {
247+
&Directive{
248+
Directive: "js_periodic",
249+
Args: []string{"function"},
250+
Line: 5,
251+
},
252+
blockCtx{"stream", "server"},
253+
false,
254+
},
228255
}
229256

230257
for name, tc := range testcases {
231258
tc := tc
232259
t.Run(name, func(t *testing.T) {
233260
t.Parallel()
234261
err := analyze("nginx.conf", tc.stmt, ";", tc.ctx, &ParseOptions{})
235-
236262
if !tc.wantErr && err != nil {
237263
t.Fatal(err)
238264
}

0 commit comments

Comments
 (0)