Skip to content

Commit

Permalink
Merge pull request #6718 from CommanderRoot/refactor/rm-deprecated-su…
Browse files Browse the repository at this point in the history
…bstr

refactor: replace deprecated String.prototype.substr()
  • Loading branch information
kulmann authored Apr 12, 2022
2 parents 186139d + 7e5f04a commit 1059de9
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 7 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/enhancement-replace-deprecated-substr
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Replace deprecated String.prototype.substr()

We've replaced all occurrences of the deprecated String.prototype.substr()
function with String.prototype.slice() which works similarly but isn't
deprecated.

https://github.com/owncloud/web/pull/6718
2 changes: 1 addition & 1 deletion packages/web-app-files/src/mixins/actions/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default {
this.hideModal()

if (sameResource) {
const newPath = resource.path.substr(1, resource.path.lastIndexOf('/'))
const newPath = resource.path.slice(1, resource.path.lastIndexOf('/') + 1)
this.$router.push({
params: {
item: '/' + newPath + newName || '/'
Expand Down
3 changes: 2 additions & 1 deletion packages/web-app-files/src/mixins/deleteResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ export default {
isSameResource(this.resourcesToDelete[0], this.currentFolder)
) {
const resourcePath = this.resourcesToDelete[0].path
parentFolderPath = resourcePath.substr(0, resourcePath.lastIndexOf('/'))
const lastSlash = resourcePath.lastIndexOf('/')
parentFolderPath = resourcePath.slice(0, lastSlash !== -1 ? lastSlash : 0)
}

if (parentFolderPath !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default {
},
renameFile(context, { file, newValue, client, publicPage, isSameResource }) {
if (file !== undefined && newValue !== undefined && newValue !== file.name) {
const newPath = file.webDavPath.substr(1, file.webDavPath.lastIndexOf('/'))
const newPath = file.webDavPath.slice(1, file.webDavPath.lastIndexOf('/') + 1)
if (publicPage) {
return client.publicFiles
.move(file.webDavPath, newPath + newValue, context.getters.publicLinkPassword)
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-preview/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default {
y: this.thumbDimensions,
// strip double quotes from etag
// we have no etag, e.g. on shared with others page
c: this.activeFilteredFile.etag?.substr(1, this.activeFilteredFile.etag.length - 2),
c: this.activeFilteredFile.etag?.slice(1, -1),
scalingup: 0,
preview: 1,
a: 1
Expand Down
4 changes: 2 additions & 2 deletions packages/web-runtime/src/components/Topbar/Notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default {
this.$client.requests
.ocs({
service: 'apps/' + app,
action: link.substr(link.lastIndexOf('api')),
action: link.slice(link.lastIndexOf('api')),
method: type
})
.then((res) => {
Expand All @@ -86,7 +86,7 @@ export default {
})
res.json().then((json) => {
json.ocs.data.forEach((item) => {
const path = item.path.substr(0, item.path.lastIndexOf('/') + 1)
const path = item.path.slice(0, item.path.lastIndexOf('/') + 1)
const absolutePath = this.$route.params.item ? this.$route.params.item : '/'
if (path === absolutePath) this.reloadFilesList(path)
})
Expand Down
3 changes: 2 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ const plugins = [
}
files[c].forEach((f) => {
const fp = path.parse(f.fileName)
const lastDash = fp.name.lastIndexOf('-')
acc[c][
production ? fp.name.substr(0, fp.name.lastIndexOf('-')) || fp.name : fp.name
production ? fp.name.slice(0, lastDash !== -1 ? lastDash : 0) || fp.name : fp.name
] = c === 'js' ? fp.name : f.fileName
})

Expand Down

0 comments on commit 1059de9

Please sign in to comment.