/
SasIPRange.ts
40 lines (38 loc) · 956 Bytes
/
SasIPRange.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
/**
* Allowed IP range for a SAS.
*
* @export
* @interface SasIPRange
*/
export interface SasIPRange {
/**
* Starting IP address in the IP range.
* If end IP doesn't provide, start IP will the only IP allowed.
*
* @type {string}
* @memberof SasIPRange
*/
start: string;
/**
* Optional. IP address that ends the IP range.
* If not provided, start IP will the only IP allowed.
*
* @type {string}
* @memberof SasIPRange
*/
end?: string;
}
/**
* Generate SasIPRange format string. For example:
*
* "8.8.8.8" or "1.1.1.1-255.255.255.255"
*
* @export
* @param {SasIPRange} ipRange A range of IP addresses.
* @returns {string} string representation of the IP range.
*/
export function ipRangeToString(ipRange: SasIPRange): string {
return ipRange.end ? `${ipRange.start}-${ipRange.end}` : ipRange.start;
}