Skip to content

Commit

Permalink
fix: replace deprecated String.prototype.substr() (protobufjs#1701)
Browse files Browse the repository at this point in the history
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
  • Loading branch information
CommanderRoot authored Jul 7, 2022
1 parent dadc65e commit e33a84a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ function parse(source, root, options) {
option = name;
token = peek();
if (fqTypeRefRe.test(token)) {
propName = token.substr(1); //remove '.' before property name
propName = token.slice(1); //remove '.' before property name
name += token;
next();
}
Expand Down
4 changes: 2 additions & 2 deletions src/wrappers.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ wrappers[".google.protobuf.Any"] = {
if (type) {
// type_url does not accept leading "."
var type_url = object["@type"].charAt(0) === "." ?
object["@type"].substr(1) : object["@type"];
object["@type"].slice(1) : object["@type"];
// type_url prefix is optional, but path seperator is required
if (type_url.indexOf("/") === -1) {
type_url = "/" + type_url;
Expand Down Expand Up @@ -87,7 +87,7 @@ wrappers[".google.protobuf.Any"] = {
if (!(message instanceof this.ctor) && message instanceof Message) {
var object = message.$type.toObject(message, options);
var messageName = message.$type.fullName[0] === "." ?
message.$type.fullName.substr(1) : message.$type.fullName;
message.$type.fullName.slice(1) : message.$type.fullName;
// Default to type.googleapis.com prefix if no prefix is used
if (prefix === "") {
prefix = googleApi;
Expand Down

0 comments on commit e33a84a

Please sign in to comment.