Skip to content

Commit e33a84a

Browse files
fix: replace deprecated String.prototype.substr() (#1701)
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher <[email protected]>
1 parent dadc65e commit e33a84a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/parse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ function parse(source, root, options) {
576576
option = name;
577577
token = peek();
578578
if (fqTypeRefRe.test(token)) {
579-
propName = token.substr(1); //remove '.' before property name
579+
propName = token.slice(1); //remove '.' before property name
580580
name += token;
581581
next();
582582
}

src/wrappers.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ wrappers[".google.protobuf.Any"] = {
4949
if (type) {
5050
// type_url does not accept leading "."
5151
var type_url = object["@type"].charAt(0) === "." ?
52-
object["@type"].substr(1) : object["@type"];
52+
object["@type"].slice(1) : object["@type"];
5353
// type_url prefix is optional, but path seperator is required
5454
if (type_url.indexOf("/") === -1) {
5555
type_url = "/" + type_url;
@@ -87,7 +87,7 @@ wrappers[".google.protobuf.Any"] = {
8787
if (!(message instanceof this.ctor) && message instanceof Message) {
8888
var object = message.$type.toObject(message, options);
8989
var messageName = message.$type.fullName[0] === "." ?
90-
message.$type.fullName.substr(1) : message.$type.fullName;
90+
message.$type.fullName.slice(1) : message.$type.fullName;
9191
// Default to type.googleapis.com prefix if no prefix is used
9292
if (prefix === "") {
9393
prefix = googleApi;

0 commit comments

Comments
 (0)