Skip to content

Commit

Permalink
Merge pull request #716 from CommanderRoot/refactor/rm-deprecated-substr
Browse files Browse the repository at this point in the history
Replace deprecated String.prototype.substr()
  • Loading branch information
tacruc authored Apr 14, 2022
2 parents 280cabe + 704000f commit 8b46b50
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ module.exports = {
'@nextcloud'
],
rules: {
'no-restricted-properties': [
'error',
{ property: 'substr', message: 'Use .slice instead of .substr.' },
],
'jsdoc/require-jsdoc': 'off',
'jsdoc/tag-lines': 'off',
'vue/first-attribute-linebreak': 'off'
Expand Down
16 changes: 8 additions & 8 deletions src/contactsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ ContactsController.prototype = {
for (var i = 0; i < contacts.length; i++) {

var geo = [];
if (contacts[i].GEO.substr(0,4) === "geo:") {
geo = contacts[i].GEO.substr(4).split(",");
if (contacts[i].GEO.slice(0,4) === "geo:") {
geo = contacts[i].GEO.slice(4).split(",");
} else {
geo = contacts[i].GEO.split(";");
}
Expand All @@ -429,12 +429,12 @@ ContactsController.prototype = {
date = new Date();
}
if (isNaN(date)) {
var year = parseInt(contacts[i].REV.substr(0,4));
var month = parseInt(contacts[i].REV.substr(4,2))-1;
var day = parseInt(contacts[i].REV.substr(6,2))-1;
var hour = parseInt(contacts[i].REV.substr(9,2))-1;
var min = parseInt(contacts[i].REV.substr(11,2))-1;
var sec = parseInt(contacts[i].REV.substr(13,2))-1;
var year = parseInt(contacts[i].REV.slice(0,4));
var month = parseInt(contacts[i].REV.slice(4,6))-1;
var day = parseInt(contacts[i].REV.slice(6,8))-1;
var hour = parseInt(contacts[i].REV.slice(9,11))-1;
var min = parseInt(contacts[i].REV.slice(11,13))-1;
var sec = parseInt(contacts[i].REV.slice(13,15))-1;
date = new Date(year,month,day,hour,min,sec);
date = date.getTime();
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/mapUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ export const getShouldMapUseImperial = () => {

export const geoToLatLng = (geo) => {
let ll
const fourFirsts = geo.substr(0, 4)
const fourFirsts = geo.slice(0, 4)
if (fourFirsts === 'geo:') {
ll = geo.substr(4).split(',')
ll = geo.slice(4).split(',')
} else {
ll = geo.split(';')
}
Expand Down

0 comments on commit 8b46b50

Please sign in to comment.