Skip to content

Commit 395749c

Browse files
authored
feat(IpAddress): paste url support port (#7377)
* feat: 支持端口 * chore: bump version 10.1.4-beta08
1 parent 6ecb251 commit 395749c

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/BootstrapBlazor/Components/IpAddress/IpAddress.razor.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,22 @@ export function init(id, invoke) {
9595
if (!raw) {
9696
return;
9797
}
98-
const parts = raw.replace(/[^\d.]/g, '').split('.').filter(p => p.length);
98+
99+
const ipRegex = /\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/;
100+
const match = raw.match(ipRegex);
101+
const parts = match ? match[0] : null;
102+
if (parts === null) {
103+
return;
104+
}
105+
99106
const cells = el.querySelectorAll(".ipv4-cell");
100107
let pos = 0;
101108
const args = [];
102-
parts.forEach(p => {
109+
parts.split('.').forEach(p => {
103110
if (pos > 3) {
104111
return;
105112
}
106-
const num = Math.max(0, Math.min(255, parseInt(p, 10) || 0));
113+
const num = parseInt(p, 10);
107114
args.push(num);
108115
cells[pos].value = num.toString();
109116
ip.prevValues[pos] = cells[pos].value;

0 commit comments

Comments
 (0)