I think that mid/substring should fixed in webCoRE since being able to omit the second parameter is expected behavior for standard implementations of this function.
It looks like the intention was to use the default behavior of String.substring
when the third parameter is omitted, but it’s not done in a supported way. I would advise changing this line in the webCoRE Piston SmartApp from
result = value.substring(start, count == null ? null : start + count)
to
if (count == null) {
result = value.substring(start)
} else {
result = value.substring(start, start + count)
}
You could leave it as a one-liner and calculate the correct length to use instead of null
, but I like this approach since it leverages the existing behavior of String.substring
. Otherwise you could calculate the proper count by including a null check in the preceding line:
if (count == null || count > value.size() - start) count = value.size() - start
result = value.substring(start, start + count)