Skip to content

Task Request#10

Open
YuliyaNovik wants to merge 5 commits intomasterfrom
request
Open

Task Request#10
YuliyaNovik wants to merge 5 commits intomasterfrom
request

Conversation

@YuliyaNovik
Copy link
Copy Markdown
Owner

No description provided.

@YuliyaNovik YuliyaNovik reopened this Sep 29, 2021
Copy link
Copy Markdown

@ArtemNikolaev ArtemNikolaev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хорошая работа, но есть некоторые архитектурные ошибки. Спрашивай если что-то будет непонятно.

const http = require("http");
const https = require("https");

const getProtocol = (url) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

протокола в урле может и не быть :-)

request/get.js Outdated

const get = (urlString) => {
return new Promise((resolve, reject) => {
try {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try catch тут не нужен
потому как ошибку .get ты уже отлавливаешь, а ошибку .on('error') ты так не поймаешь

request/get.js Outdated
try {
const url = new URL(urlString);
const protocol = getProtocol(url);
protocol.get(url, (response) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в данном месте идет сильное сцепление getProtocol и текущего кода , потому как не посмотрев внутрь не поймешь что это за метод get такой
вопрос как лучше сделать достаточно холиварный, я бы реализовал это через алиас

const requestAlias = isHttp(url) ? http : https;
requestAlias.get()

так это хотя бы в одном месте находится и не надо куда-либо ходить за ответом

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants