Comments (2)
I took a closer look into the source code for extractUrls. I didn't realise that t.co URLs were a special case! In particular, this comment seems to imply that the behaviour I'm describing is done intentionally.
// In the case of t.co URLs, don't allow additional path characters.
if (url.match(validTcoUrl)) {
...
Indeed,
twttr.txt.extractUrls("https://t.co/abc?amp=1")
["https://t.co/abc"]
twttr.txt.extractUrls("https://g.co/abc?amp=1")
["https://g.co/abc?amp=1"]
The issue arose from users copying links from twitter and pasting them onto our platform. The link has an additional ?amp=1
, so the effect is that somebody pastes https://t.co/LY1EMFy7TW?amp=1
to us, and the resulting HTML looks like <a>https://t.co/LY1EMFy7TW</a>?amp=1
.
from twitter-text.
This is not a very nice solution, but I found that if I set
(ruby)
Twitter::TwitterText::Regex::REGEXEN[:valid_tco_url] = /$^/
(js)
twttr.txt.regexen.validTcoUrl = /$^/;
then I get the behaviour I expect.
from twitter-text.
Related Issues (20)
- Autolink: Don't set the HTML title attribute on hashtag values when it's the same as the link value
- Autolink: Link to tweet URL has no context for screen readers
- core-js outdated HOT 4
- Cannot bundle install gem inside a Docker container HOT 1
- Error shortening the url HOT 4
- @ on mention is outside the anchor tag HOT 4
- Library is not made for javascript
- changes to continuous integration
- Go implements request HOT 2
- Project status HOT 1
- [QUESTION]About counting emoji character HOT 3
- Module bundler
- Example does not work... what is twttr?
- تويتر HOT 1
- pinging on getting this merged!
- since ytdl-webserver was removed a little while ago, i feel we should replace it HOT 5
- Question: Why is the Java dependency different than on Twitter SDK repository?
- Broken "Pronouns" setting not removed in the X Android App (Leftover from the pre-X era) HOT 1
- regex expression for validUrlQueryChars unable to identify URI Template
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twitter-text.