Skip to content

Commit 1b0e04e

Browse files
committed
[PRAC/ret] Exclude use "substr()" method
Correct server logic/file, replace "substr()" with "slice()" method. Deserv(s) attention: - that the "substr()" method is now deprecated (according to MDN). core: B-3 / JS-BL
1 parent 74e57b0 commit 1b0e04e

File tree

1 file changed

+2
-2
lines changed
  • core-courses/3-js-basic-level/practicum-js-basic-level/sb-crm-server

1 file changed

+2
-2
lines changed

core-courses/3-js-basic-level/practicum-js-basic-level/sb-crm-server/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ module.exports = createServer(async (req, res) => {
201201
}
202202

203203
// убираем из запроса префикс URI, разбиваем его на путь и параметры
204-
const [uri, query] = req.url.substr(URI_PREFIX.length).split("?");
204+
const [uri, query] = req.url.slice(URI_PREFIX.length).split("?");
205205
const queryParams = {};
206206

207207
// параметры могут отсутствовать вообще или иметь вид a=b&b=c
@@ -229,7 +229,7 @@ module.exports = createServer(async (req, res) => {
229229
} else {
230230
// /api/clients/{id}
231231
// параметр {id} из URI запроса
232-
const itemId = uri.substr(1);
232+
const itemId = uri.slice(1);
233233
if (req.method === "GET") return getClient(itemId);
234234
if (req.method === "PATCH")
235235
return updateClient(itemId, await drainJson(req));

0 commit comments

Comments
 (0)