dentarg / hubot-url-title

:crocodile: Returns the title when a link is posted
https://www.npmjs.com/package/hubot-url-title
4 stars 11 forks source link

encodings, multiple titles, linebreaks #7

Closed impca closed 8 years ago

impca commented 8 years ago

Hello.

You have an excellent plugin there, but there were some annoying minuscule things that I just had to fix. :)

1) Titles of webpages with an encoding that is not utf-8 are now correctly interpreted. No more garbled characters in hubot's chat output.

2) Linebreaks in titles are now discarded.

3) If a page contains multiple title tags, only the contents of the first one is used.

marissacute commented 8 years ago

:+1:

dentarg commented 8 years ago

hey @impca seems like awesome work here but I'm curious about 1), do you have any example of a URL that caused a problem regarding that?

I tried to re-create that problem myself, I have a non UTF-8 site at https://huvud.herokuapp.com/latin1 and using the shell adapter:

the current version

myhubot> https://huvud.herokuapp.com/latin1
myhubot> åäö foo

and here is your code

edgehubot> https://huvud.herokuapp.com/latin1
edgehubot> åäö foo
marissacute commented 8 years ago

"åäö foo" is what I see on Firefox, Edge and Chrome as title when I go to that website.

dentarg commented 8 years ago

Hmm I think I did something wrong with the test site, will check later tonight

dentarg commented 8 years ago

I fixed the test site and now it's the current version that have problems :) thanks again @impca

myhubot> https://huvud.herokuapp.com/latin1
myhubot> ��� foo

edgehubot> https://huvud.herokuapp.com/latin1
edgehubot> åäö foo