G
G
goshva2016-10-20 19:34:11
JavaScript
goshva, 2016-10-20 19:34:11

How does a link shortener work?

You need to write your own link shortener like goo.gl .
The link looks like this:

https://boggle.space/url
?edge=10
&letters="т","о","с","т","е","р","г","р","т","н","о","в","ь","ю","с","ш","о","т","о","а","з","н","о","н","ы","м","к","л","ш","и","л","л","р","г","м","н","я","н","н","а","у","о","о","г","н","е","л","е","о","б","д","т","е","и","п","о","с","т","о","о","с","и","в","л","г","ж","к","и","е","н","п","ц","к","и","о","м","л","л","а","а","а","й","с","о","а","а","у","а","а","л","д","х","а","ь","б","ж","у","в","е","о"]
&userwordsids=

I ask you to outline the basic scheme of the link shortener operation
(I considered the API - it doesn’t fit, you need your own).
I would also like to know which tools are preferable to use in conjunction with nodejs to store the corresponding links.
Thanks to.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
D', 2016-10-20
@Denormalization

It's simple:
- We generate a unique ID for the link
- We save this ID in the database along with the link
- When someone requests http://yoursite.ru/[ID] we get the link from the database that is tied to this ID and redirect.

A
Alexey Ukolov, 2016-10-20
@alexey-m-ukolov

Principal diagram:

  1. Create a urls table with two columns - short and full .
  2. Генерируете короткие адреса по любому алгоритму. Да хоть ID строки используйте, хоть таймстамп, хоть UUID - что угодно. Вряд ли для ваших целей критично, поместится ли ссылка в Твит.
  3. Всё.

Петр, 2016-10-20
@petermzg

Берете урл. По нему md5 и затем base64
Записываете в базу получившееся значение и url.
Итог: http://<ваш домен>/<получившийся base64>
Если идет обращение, то по части ищете в базе и возвращаете редирект на url сохраненый в базе

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question