Skip to content

Commit

Permalink
fix: replace deprecated String.prototype.substr() (#68)
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 Apr 5, 2022
1 parent 021b97b commit b146f20
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/lines-to-revs.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ const lineToRevDoc = line => {
// ignore the pointer.
// For now, though, we have to save both, because some tags
// don't have peels, if they were not annotated.
const ref = rawRef.substr('refs/tags/'.length)
const ref = rawRef.slice('refs/tags/'.length)
return { sha, ref, rawRef, type }
}

if (type === 'branch') {
const ref = rawRef.substr('refs/heads/'.length)
const ref = rawRef.slice('refs/heads/'.length)
return { sha, ref, rawRef, type }
}

if (type === 'pull') {
// NB: merged pull requests installable with #pull/123/merge
// for the merged pr, or #pull/123 for the PR head
const ref = rawRef.substr('refs/'.length).replace(/\/head$/, '')
const ref = rawRef.slice('refs/'.length).replace(/\/head$/, '')
return { sha, ref, rawRef, type }
}

Expand Down

0 comments on commit b146f20

Please sign in to comment.