From 6e1c756e971d307dbeb6fc76056d2a4264fbdec4 Mon Sep 17 00:00:00 2001 From: Tobias Speicher Date: Thu, 24 Mar 2022 00:04:31 +0100 Subject: [PATCH] refactor: replace deprecated String.prototype.substr() .substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher --- examples/react-todo-list/src/components/Home.js | 2 +- .../interfaces/Database/Functions/CreateFunction.tsx | 5 +++-- studio/pages/project/[ref]/api/index.tsx | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/react-todo-list/src/components/Home.js b/examples/react-todo-list/src/components/Home.js index 3c9f53103c2..ad432108d01 100644 --- a/examples/react-todo-list/src/components/Home.js +++ b/examples/react-todo-list/src/components/Home.js @@ -15,7 +15,7 @@ const Home = ({ user }) => { * Read more on https://supabase.com/docs/reference/javascript/reset-password-email#notes */ let url = window.location.hash; - let query = url.substr(1); + let query = url.slice(1); let result = {}; query.split("&").forEach((part) => { diff --git a/studio/components/interfaces/Database/Functions/CreateFunction.tsx b/studio/components/interfaces/Database/Functions/CreateFunction.tsx index 07443b9bf8a..dafd57350fe 100644 --- a/studio/components/interfaces/Database/Functions/CreateFunction.tsx +++ b/studio/components/interfaces/Database/Functions/CreateFunction.tsx @@ -101,8 +101,9 @@ function convertArgumentTypes(value: string) { if (isEmpty(value) || !items || items?.length == 0) return { value: [] } const temp = items.map((x) => { const str = x.trim() - const name = str.substr(0, str.indexOf(' ')) - const type = str.substr(str.indexOf(' ') + 1) + const space = str.indexOf(' ') + const name = str.slice(0, space !== 1 ? space : 0) + const type = str.slice(space + 1) return { name, type } }) return { value: temp } diff --git a/studio/pages/project/[ref]/api/index.tsx b/studio/pages/project/[ref]/api/index.tsx index 725c2ec4d05..6ae2714af8c 100644 --- a/studio/pages/project/[ref]/api/index.tsx +++ b/studio/pages/project/[ref]/api/index.tsx @@ -34,7 +34,7 @@ const PageConfig = () => { let rpcs: any = {} Object.entries(paths || []).forEach(([name, val]) => { - let trimmed = name.substr(1) + let trimmed = name.slice(1) let id = trimmed.replace(functionPath, '') let displayName = id.replace(/_/g, ' ') let camelCase = snakeToCamel(id)