Skip to content

Commit ec6715b

Browse files
committed
feat: Empty rows in the expressions configuration don't result in any-regexps
1 parent d376474 commit ec6715b

File tree

3 files changed

+149
-1
lines changed

3 files changed

+149
-1
lines changed

lib/api/Configuration.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ export class Configuration {
178178

179179
// Load exceptions
180180

181-
this.exceptions = this._getConfigurationFromPanel($, 'Exceptions').map<RegExp>((value) => new RegExp(value.regularexpression))
181+
this.exceptions = this._getConfigurationFromPanel($, 'Exceptions')
182+
.filter((value) => value.regularexpression !== '')
183+
.map<RegExp>((value) => new RegExp(value.regularexpression))
182184

183185
this.notificationSubjectTemplate = $(
184186
'ac\\:parameter:contains("Notification Template") + ac\\:rich-text-body ac\\:parameter:contains("Subject") + ac\\:rich-text-body'

test/ConfigurationTest.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,13 @@ describe('The Configuration API', (): void => {
2828

2929
chai.expect(configuration.notificationFrom).to.eq('Notification <noreply@example.com>')
3030
})
31+
it('supports empty exclusion lines', async (): Promise<void> => {
32+
const mockServer = new MockServer('https://example.com')
33+
mockServer.addConfigurationDocumentEndpoint()
34+
35+
const configuration = new Configuration('https://example.com', 'nobody', 'nothing', '12346')
36+
await configuration.load()
37+
38+
chai.expect(configuration.exceptions).to.have.lengthOf(0)
39+
})
3140
})

test/MockServer.ts

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,143 @@ export class MockServer {
142142
</table>
143143
</ac:rich-text-body>
144144
</ac:structured-macro>
145+
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='93f1d981-c841-4cb4-b6e2-5940dfe69132'>
146+
<ac:parameter ac:name='title'>Notification Template</ac:parameter>
147+
<ac:rich-text-body>
148+
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='f8503e48-c671-4ed6-897c-def2b2c3fa29'>
149+
<ac:parameter ac:name='title'>Subject</ac:parameter>
150+
<ac:rich-text-body><p>${MockServer.NOTIFICATION_SUBJECT}</p></ac:rich-text-body>
151+
</ac:structured-macro>
152+
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='63c16112-dea3-434e-b1cb-467ff4e36d5f'>
153+
<ac:parameter ac:name='title'>Body</ac:parameter>
154+
<ac:rich-text-body>${MockServer.NOTIFICATION_BODY}</ac:rich-text-body>
155+
</ac:structured-macro>
156+
</ac:rich-text-body>
157+
</ac:structured-macro>
158+
`,
159+
},
160+
},
161+
})
162+
this._scope
163+
.get('/rest/api/content/12346?expand=body.storage')
164+
.basicAuth({
165+
user: 'nobody',
166+
pass: 'nothing',
167+
})
168+
.reply(200, {
169+
body: {
170+
storage: {
171+
value: `
172+
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='4671afbe-d914-470a-bb9e-8b7321f60f79'>
173+
<ac:parameter ac:name='title'>Configuration</ac:parameter>
174+
<ac:rich-text-body>
175+
<table class='wrapped'>
176+
<colgroup>
177+
<col/>
178+
<col/>
179+
</colgroup>
180+
<tbody>
181+
<tr>
182+
<th>Space</th>
183+
<td>SAMPLE</td>
184+
</tr>
185+
<tr>
186+
<th>Domain</th>
187+
<td>example.com</td>
188+
</tr>
189+
<tr>
190+
<th>NotificationFrom</th>
191+
<td>Notification &lt;noreply@example.com&gt;</td>
192+
</tr>
193+
</tbody>
194+
</table>
195+
</ac:rich-text-body>
196+
</ac:structured-macro>
197+
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='ecfe796e-b701-4f30-a74a-b94dbb33daff'>
198+
<ac:parameter ac:name='title'>SMTP</ac:parameter>
199+
<ac:rich-text-body>
200+
<table>
201+
<colgroup>
202+
<col/>
203+
<col/>
204+
</colgroup>
205+
<tbody>
206+
<tr>
207+
<th>Host</th>
208+
<td colspan='1'>localhost</td>
209+
</tr>
210+
<tr>
211+
<th>Port</th>
212+
<td colspan='1'>25</td>
213+
</tr>
214+
</tbody>
215+
</table>
216+
</ac:rich-text-body>
217+
</ac:structured-macro>
218+
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='f19cd8b2-57e0-4c68-a823-8a2daee08c12'>
219+
<ac:parameter ac:name='title'>Checks</ac:parameter>
220+
<ac:rich-text-body>
221+
<table class='wrapped'>
222+
<colgroup>
223+
<col/>
224+
<col/>
225+
</colgroup>
226+
<tbody>
227+
<tr>
228+
<th>Labels</th>
229+
<th>MaxAge</th>
230+
</tr>
231+
<tr>
232+
<td>test1</td>
233+
<td>356</td>
234+
</tr>
235+
<tr>
236+
<td colspan='1'>test2</td>
237+
<td colspan='1'>1234</td>
238+
</tr>
239+
</tbody>
240+
</table>
241+
</ac:rich-text-body>
242+
</ac:structured-macro>
243+
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='1d192d60-7e69-4af8-8dd6-4006a7bfc952'>
244+
<ac:parameter ac:name='title'>Maintainer</ac:parameter>
245+
<ac:rich-text-body>
246+
<table class='wrapped'>
247+
<colgroup>
248+
<col/>
249+
<col/>
250+
</colgroup>
251+
<tbody>
252+
<tr>
253+
<th>Pagepattern</th>
254+
<th>Maintainer</th>
255+
</tr>
256+
<tr>
257+
<td>main/Test/.*</td>
258+
<td>maintainer,_lastauthor</td>
259+
</tr>
260+
</tbody>
261+
</table>
262+
</ac:rich-text-body>
263+
</ac:structured-macro>
264+
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='1d192d60-7e69-4af8-8dd6-4006a7bfc952'>
265+
<ac:parameter ac:name='title'>Exceptions</ac:parameter>
266+
<ac:rich-text-body>
267+
<table class='wrapped'>
268+
<colgroup>
269+
<col/>
270+
</colgroup>
271+
<tbody>
272+
<tr>
273+
<th>RegularExpression</th>
274+
</tr>
275+
<tr>
276+
<td></td>
277+
</tr>
278+
</tbody>
279+
</table>
280+
</ac:rich-text-body>
281+
</ac:structured-macro>
145282
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='93f1d981-c841-4cb4-b6e2-5940dfe69132'>
146283
<ac:parameter ac:name='title'>Notification Template</ac:parameter>
147284
<ac:rich-text-body>

0 commit comments

Comments
 (0)