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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//! General hosts.
use crate*;
/// Possible last bytes for a domain segment that [`is_a_number`].
const NUM_SEGMENT_LASTS: ByteSet = new.add_many;
/** [`bytes_ends_in_a_number`]. */
/** [`bytes_ends_in_empty`]. */
/** [`bytes_last_is_a_number`]. */
/** [`bytes_last_is_empty`]. */
/** [`bytes_is_a_number`]. */
/// If, ignoring a trailing dot, the percent decoded and UTS46 mapped and normalized input's last dot delimited segment is a number.
/// # Examples
/// ```
/// use better_url::util::*;
///
/// assert!( bytes_ends_in_a_number(b"123"));
/// assert!( bytes_ends_in_a_number(b"123."));
/// assert!( bytes_ends_in_a_number(b"a.123"));
/// assert!( bytes_ends_in_a_number(b"a.123."));
///
/// assert!( bytes_ends_in_a_number(b"0x1f"));
/// assert!( bytes_ends_in_a_number(b"0x1f."));
/// assert!( bytes_ends_in_a_number(b"a.0x1f"));
/// assert!( bytes_ends_in_a_number(b"a.0x1f."));
///
/// assert!( bytes_ends_in_a_number(b"0x"));
/// assert!( bytes_ends_in_a_number(b"0x."));
/// assert!( bytes_ends_in_a_number(b"a.0x"));
/// assert!( bytes_ends_in_a_number(b"a.0x."));
///
/// assert!( bytes_ends_in_a_number(b"01"));
/// assert!( bytes_ends_in_a_number(b"01."));
/// assert!( bytes_ends_in_a_number(b"a.01"));
/// assert!( bytes_ends_in_a_number(b"a.01."));
/// assert!( bytes_ends_in_a_number(b"09"));
///
/// assert!(!bytes_ends_in_a_number(b"0xZ"));
/// assert!(!bytes_ends_in_a_number(b"a"));
/// assert!(!bytes_ends_in_a_number(b"a."));
/// assert!(!bytes_ends_in_a_number(b""));
/// ```
/// If, ignoring a trailing dot, the percent decoded and UTS46 mapped and normalized input's last dot delimited segment is empty.
/// If the percent decoded and UTS46 mapped and normalized input's last dot delimited segment is a number.
/// If the percent decoded and UTS46 mapped and normalized input's last dot delimited segment is empty.
/// If the value "is a number" for purposes of distinguishing between IPv4 hosts and domain hosts.
///
/// Assumes the input has already been percent decoded and UTS46 normalized.
///
/// Specifically, `^0x[0-9a-f]|[0-9]+$`
///
/// Per the spec, even if a number is too big to be an IPv4 segment (such as 99999999999999999), it still counts as a number for IPv4 parsing.
/// # Examples
/// ```
/// use better_url::util::*;
///
/// assert!(!bytes_is_a_number(b"" ));
/// assert!( bytes_is_a_number(b"0" ));
/// assert!( bytes_is_a_number(b"10" ));
/// assert!( bytes_is_a_number(b"1000000000000"));
/// assert!(!bytes_is_a_number(b"a0" ));
/// assert!(!bytes_is_a_number(b"a000000000000"));
///
/// assert!( bytes_is_a_number(b"0x" ));
/// assert!( bytes_is_a_number(b"0x0" ));
/// assert!( bytes_is_a_number(b"0x10" ));
/// assert!( bytes_is_a_number(b"0x1000000000000"));
/// assert!( bytes_is_a_number(b"0xa0" ));
/// assert!( bytes_is_a_number(b"0xa000000000000"));
/// ```