mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-09 07:45:00 -04:00
Minor fixes
This commit is contained in:
parent
588cd93900
commit
200fbb2360
2 changed files with 8 additions and 8 deletions
|
@ -345,7 +345,7 @@ export function ipv4ToStr(ipInt) {
|
||||||
* @example
|
* @example
|
||||||
* // returns [65280, 0, 0, 0, 0, 0, 4369, 8738]
|
* // returns [65280, 0, 0, 0, 0, 0, 4369, 8738]
|
||||||
* strToIpv6("ff00::1111:2222");
|
* strToIpv6("ff00::1111:2222");
|
||||||
*
|
*
|
||||||
* // returns 126946n
|
* // returns 126946n
|
||||||
* strToIpv6("1:f000", false);
|
* strToIpv6("1:f000", false);
|
||||||
*/
|
*/
|
||||||
|
@ -356,7 +356,6 @@ export function strToIpv6(ipStr, retArr=true) {
|
||||||
ipStr = "0" + ipStr;
|
ipStr = "0" + ipStr;
|
||||||
}
|
}
|
||||||
return BigInt("0x" + ipStr.replace(":", ""));
|
return BigInt("0x" + ipStr.replace(":", ""));
|
||||||
return
|
|
||||||
}
|
}
|
||||||
let j = 0;
|
let j = 0;
|
||||||
const blocks = ipStr.split(":"),
|
const blocks = ipStr.split(":"),
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Sort extends Operation {
|
||||||
sorted = sorted.sort(Sort._caseInsensitiveSort);
|
sorted = sorted.sort(Sort._caseInsensitiveSort);
|
||||||
} else if (order === "IPv4 address") {
|
} else if (order === "IPv4 address") {
|
||||||
sorted = sorted.sort(Sort._ipv4Sort);
|
sorted = sorted.sort(Sort._ipv4Sort);
|
||||||
} else if (order == "IPv6 address") {
|
} else if (order === "IPv6 address") {
|
||||||
sorted = sorted.sort(Sort._ipv6Sort);
|
sorted = sorted.sort(Sort._ipv6Sort);
|
||||||
} else if (order === "Numeric") {
|
} else if (order === "Numeric") {
|
||||||
sorted = sorted.sort(Sort._numericSort);
|
sorted = sorted.sort(Sort._numericSort);
|
||||||
|
@ -109,14 +109,15 @@ class Sort extends Operation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comparison operator for sorting of IPv6 addresses.
|
* Comparison operator for sorting of IPv6 addresses.
|
||||||
*
|
*
|
||||||
* @param {string} a
|
* @param {string} a
|
||||||
* @param {string} b
|
* @param {string} b
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
static _ipv6Sort(a, b) {
|
static _ipv6Sort(a, b) {
|
||||||
const numericalA = strToIpv6(a, false),
|
const ipLib = require("../lib/IP.mjs");
|
||||||
numericalB = strToIpv6(b, false);
|
const numericalA = ipLib.strToIpv6(a, false),
|
||||||
|
numericalB = ipLib.strToIpv6(b, false);
|
||||||
return numericalA < numericalB ? -1 : 1;
|
return numericalA < numericalB ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue