0
  • I have only one input (type=text), in this input someone will type his text and he can paste a link in this field also.
  • What I should to do? I should initialize this link in text for beautiful link preview(for this I'll use link-preview-js).
  • So, please, help me to initialize a link
  • Using: react, reactTS

Input:

The URL() constructor returns a newly created URL object representing the URL defined by the parameters. If the given base URL or the resulting URL are not valid URLs, the JavaScript TypeError exception is thrown. www.gfokgfkl.com (and preview under)

Expect some methods or special type like File -> FileReader for(for ex) images.

AVT
  • 47
  • 3

1 Answers1

0

You might want to use a regex. This answer has a good regex to match links. And then you can use String.prototype.match to extract the link from your input.

Bora Ciner
  • 121
  • 1
  • 6