DIRECTcut/ytb--down

Error on invalid ID input

Closed this issue · 1 comments

Expected Behavior

When an invalid ID is submitted, the app notifies the user and empties the input.

Current Behavior

App crashes (JS emits an error and everything hangs) if the user submits an invalid link (one that does not include a YT video ID).

The server emits an error when it receives an invalid ID input. This error gets sent to the client as a string, the client expects JSON and fires an error.

Page reload helps.

Possible Solution

Validate user input server-side with ytdl.validateID(). On error, send it as JSON to client.
Check for the error on the client and parse it accordingly.

OR

Validate client-side with a regex: [a-zA-Z0-9_-]{11}
SOURCE

However, if the format is valid, but the video doesn't exist, an error is anticipated (haven't checked that);

Steps to Reproduce

  1. Open the app.
  2. Paste invalid data into the linkInput.
  3. Press 'Submit'

Implemented client-side validation in master
Commit