Skip to content

Commit 93434d3

Browse files
CommanderRootKevinRoebert
authored andcommitted
Replace deprecated String.prototype.substr()
String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with startsWith() or endsWith() Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
1 parent 42268bf commit 93434d3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

core_js/tools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ function decodeURL(url) {
288288
}
289289

290290
// Required (e.g., to fix https://github.com/ClearURLs/Addon/issues/71)
291-
if(rtn.substr(0, 4) !== 'http') {
291+
if(!rtn.startsWith('http')) {
292292
rtn = 'http://'+rtn
293293
}
294294

external_js/ip-range-check.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,10 @@ function check_single_cidr(addr, cidr) {
484484
while ((lastColon = string.indexOf(':', lastColon + 1)) >= 0) {
485485
colonCount++;
486486
}
487-
if (string.substr(0, 2) === '::') {
487+
if (string.startsWith('::')) {
488488
colonCount--;
489489
}
490-
if (string.substr(-2, 2) === '::') {
490+
if (string.endsWith('::')) {
491491
colonCount--;
492492
}
493493
if (colonCount > parts) {

0 commit comments

Comments
 (0)