nojimage/twitter-text-php

"@" symbol should be included in anchor for mentions

kinglozzer opened this issue · 8 comments

Autolinked @username mentions result in a URL like @<a href="twitter.com/username">username</a>, when the @ symbol should be included as part of the anchor

Hi!

That's correct, it should be like @username.

Official twitter text javascript library result: https://codesandbox.io/s/3849wo8p5

Twitter used to be like https://twitter.com/@jack and later changed it to https://twitter.com/jack

Thanks!

I disagree - if you use the official Twitter iOS/Android app, or browse twitter.com in a web browser, the ‘@‘ is always included in the link

Sure, you can create a new issue here https://github.com/twitter/twitter-text/issues/new

Thanks!

No need, I guess it’s just a feature missing from this implementation :) https://codesandbox.io/s/kjynx6ro3

Good catch! Probably we can add this feature? What do you think @nojimage ?

Thanks comments. I'll try implements usernameIncludeSymbol option.

Hi @kinglozzer, I implemented setUsernameIncludeSymbol().
please try it.

$linker = new Autolink();
$linker->setUsernameIncludeSymbol(true);
$linkedText = $linker->autoLink('@username'); // -> '<a href="twitter.com/username">@username</a>'

Great, works perfectly. Thanks @nojimage @sololance 😀