angular-linkify
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -29,4 +29,4 @@ angular.module('linkify', []); | ||
if (type === 'twitter') { | ||
_text = _text.replace(/(|\s)*@([a-zA-Z0-9àáâãäåçèéêëìíîïðòóôõöùúûüýÿñ_-]+)/g, '$1<a href="https://twitter.com/$2" target="_blank">@$2</a>'); | ||
_text = _text.replace(/(^|\s)*#([a-zA-Z0-9àáâãäåçèéêëìíîïðòóôõöùúûüýÿñ_-]+)/g, '$1<a href="https://twitter.com/search?q=%23$2" target="_blank">#$2</a>'); | ||
_text = _text.replace(/(|\s)*@([\u00C0-\u1FFF\w]+)/g, '$1<a href="https://twitter.com/$2" target="_blank">@$2</a>'); | ||
_text = _text.replace(/(^|\s)*#([\u00C0-\u1FFF\w]+)/g, '$1<a href="https://twitter.com/search?q=%23$2" target="_blank">#$2</a>'); | ||
} | ||
@@ -33,0 +33,0 @@ |
/* | ||
angular-linkify - v1.0.0 - 9/16/2014 | ||
angular-linkify - v1.1.0 - 12/22/2014 | ||
Angular filter to linkify urls, "@" usernames, and hashtags. | ||
Copyright (c) 2014 ; Licensed | ||
*/ | ||
angular.module("linkify",[]),angular.module("linkify").filter("linkify",function(){"use strict";function linkify(_str,type){if(_str){var _text=_str.replace(/(?:https?\:\/\/|www\.)+(?![^\s]*?")([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/gi,function(url){var wrap=document.createElement("div"),anch=document.createElement("a");return anch.href=url,anch.target="_blank",anch.innerHTML=url,wrap.appendChild(anch),wrap.innerHTML});return _text?("twitter"===type&&(_text=_text.replace(/(|\s)*@([a-zA-Z0-9àáâãäåçèéêëìíîïðòóôõöùúûüýÿñ_-]+)/g,'$1<a href="https://twitter.com/$2" target="_blank">@$2</a>'),_text=_text.replace(/(^|\s)*#([a-zA-Z0-9àáâãäåçèéêëìíîïðòóôõöùúûüýÿñ_-]+)/g,'$1<a href="https://twitter.com/search?q=%23$2" target="_blank">#$2</a>')),"github"===type&&(_text=_text.replace(/(|\s)*@(\w+)/g,'$1<a href="https://github.com/$2" target="_blank">@$2</a>')),_text):""}}return function(text,type){return linkify(text,type)}}).factory("linkify",["$filter",function($filter){"use strict";function _linkifyAsType(type){return function(str){return $filter("linkify")(str,type)}}return{twitter:_linkifyAsType("twitter"),github:_linkifyAsType("github"),normal:_linkifyAsType()}}]).directive("linkify",["$filter","$timeout","linkify",function($filter,$timeout,linkify){"use strict";return{restrict:"A",link:function(scope,element,attrs){var type=attrs.linkify||"normal";$timeout(function(){element.html(linkify[type](element.html()))})}}}]); | ||
angular.module("linkify",[]),angular.module("linkify").filter("linkify",function(){"use strict";function linkify(_str,type){if(_str){var _text=_str.replace(/(?:https?\:\/\/|www\.)+(?![^\s]*?")([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/gi,function(url){var wrap=document.createElement("div"),anch=document.createElement("a");return anch.href=url,anch.target="_blank",anch.innerHTML=url,wrap.appendChild(anch),wrap.innerHTML});return _text?("twitter"===type&&(_text=_text.replace(/(|\s)*@([\u00C0-\u1FFF\w]+)/g,'$1<a href="https://twitter.com/$2" target="_blank">@$2</a>'),_text=_text.replace(/(^|\s)*#([\u00C0-\u1FFF\w]+)/g,'$1<a href="https://twitter.com/search?q=%23$2" target="_blank">#$2</a>')),"github"===type&&(_text=_text.replace(/(|\s)*@(\w+)/g,'$1<a href="https://github.com/$2" target="_blank">@$2</a>')),_text):""}}return function(text,type){return linkify(text,type)}}).factory("linkify",["$filter",function($filter){"use strict";function _linkifyAsType(type){return function(str){return $filter("linkify")(str,type)}}return{twitter:_linkifyAsType("twitter"),github:_linkifyAsType("github"),normal:_linkifyAsType()}}]).directive("linkify",["$filter","$timeout","linkify",function($filter,$timeout,linkify){"use strict";return{restrict:"A",link:function(scope,element,attrs){var type=attrs.linkify||"normal";$timeout(function(){element.html(linkify[type](element.html()))})}}}]); |
{ | ||
"name": "angular-linkify", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "angular-linkify.js", | ||
@@ -5,0 +5,0 @@ "description": "Angular filter to linkify urls, \"@\" usernames, and hashtags.", |
{ | ||
"name": "angular-linkify", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Angular filter to linkify urls, \"@\" usernames, and hashtags.", | ||
@@ -5,0 +5,0 @@ "main": "angular-linkify.js", |
@@ -1,2 +0,2 @@ | ||
l# angular-linkify | ||
# angular-linkify | ||
@@ -19,3 +19,3 @@ Angular filter, directive, and service to linkify text. As of **v0.3.0**, angular-linkify works for twitter/github mentions, twitter hashtags, and basic urls. | ||
Use as a [AngularJS Filter](http://docs.angularjs.org/guide/dev_guide.templates.filters.using_filters) or [AngularJS Directive](http://docs.angularjs.org/guide/directive) | ||
Use as a [AngularJS Directive](http://docs.angularjs.org/guide/directive) | ||
@@ -39,3 +39,3 @@ ```html | ||
// Must use $sce.trustAsHtml() as of Angular 1.2.x | ||
$scope.text = $sce.trustAsHtmllinkify.twitter(text)); | ||
$scope.text = $sce.trustAsHtml(linkify.twitter(text)); | ||
// outputs: <a href="https://twitter.com/scottcorgan" target="_blank">scottcorgan</a> and <a href="http://github.com" target="_blank">http://github.com</a> | ||
@@ -42,0 +42,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8538