Skip to content

Commit 2e7e4a0

Browse files
authored
Rearrange firewall rules form and add help text (#2190)
* rearrange firewall rules form and add help text * move priority to the bottom of the top section, add help text * rearrange filters and fix typographic hierarchy * validate port range, both syntax and dupe * improve targets help text, thanks @taspelund
1 parent 1e576fc commit 2e7e4a0

File tree

4 files changed

+201
-127
lines changed

4 files changed

+201
-127
lines changed

app/api/util.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ describe('parsePortRange', () => {
2323
expect(parsePortRange('1-45690')).toEqual([1, 45690])
2424
expect(parsePortRange('5-5')).toEqual([5, 5])
2525
})
26+
27+
it('with surrounding whitespace', () => {
28+
expect(parsePortRange('123-456 ')).toEqual([123, 456])
29+
expect(parsePortRange(' 1-45690')).toEqual([1, 45690])
30+
expect(parsePortRange(' 5-5 \n')).toEqual([5, 5])
31+
})
2632
})
2733

2834
describe('rejects', () => {

app/api/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type PortRange = [number, number]
4545
// null so we can annotate the failure with a reason
4646
export function parsePortRange(portRange: string): PortRange | null {
4747
// TODO: pull pattern from openapi spec (requires generator work)
48-
const match = /^([0-9]{1,5})((?:-)[0-9]{1,5})?$/.exec(portRange)
48+
const match = /^([0-9]{1,5})((?:-)[0-9]{1,5})?$/.exec(portRange.trim())
4949
if (!match) return null
5050

5151
const p1 = parseInt(match[1], 10)

0 commit comments

Comments
 (0)