Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

Commit

Permalink
Merge pull request #74 from w3c/tripu/support-twitter
Browse files Browse the repository at this point in the history
Support services of type “twitter”
  • Loading branch information
tripu authored Mar 23, 2017
2 parents c629f5a + f79bdd8 commit acd8ed2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
11 changes: 10 additions & 1 deletion behaviour.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict';

var VERSION = '2.2.0',
var VERSION = '2.3.0',
API_KEY = 'f093zc7jyxskgscw0kkgk4w4go0w80k',
DEBUG = false,
OPTS = {embed: true},
REGEX_URI = /^(https?|irc):\/\/(www\.)?((.+)[^\ \/])\/?$/i,
TWITTER_URI = /^https?:\/\/(www\.)?twitter.com\/([^\ \/]+)\/?$/i,
REGEX_DATE = /^[\d\-\/\.\ ]{8,10}$/i,
MODE = 'param',
TYPE_W3C = 'w3c',
Expand Down Expand Up @@ -381,6 +382,14 @@ var init = function(api) {
<span class="suffix">(RSS)</span>
</a>
</li>`;
} else if ('twitter' === entity.type) {
// Twitter:
result = `<li class="list-group-item">
<a href="${buildLink(entity._links.self.href)}">
<code>${normaliseURI(entity.link)}</code>
<span class="suffix">(Twitter)</span>
</a>
</li>`;
} else {
result = `<li class="list-group-item">[Unknown type of service]</li>\n`;
}
Expand Down
12 changes: 8 additions & 4 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ var abbreviateGroupName = function(name) {
var normaliseURI = function(uri) {

var result = uri.trim(); // .toLowerCase();
var matches = REGEX_URI.exec(result);

if (matches && matches.length > 3) {
result = matches[3];
var matches = TWITTER_URI.exec(result);

if (matches && matches.length > 2)
result = `@${matches[2]}`;
else {
matches = REGEX_URI.exec(result);
if (matches && matches.length > 3)
result = matches[3];
}

return result;
Expand Down

0 comments on commit acd8ed2

Please sign in to comment.