Skip to content

Commit

Permalink
Merge pull request #40 from alexcorvi
Browse files Browse the repository at this point in the history
1.0.2
  • Loading branch information
alexcorvi authored Feb 28, 2017
2 parents ba150a9 + a66882f commit cea5593
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 48 deletions.
16 changes: 7 additions & 9 deletions dist-browser/anchorme.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist-browser/anchorme.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist-node/lists.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist-node/tests/ip.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
var util_1 = require("../util");
// general IP pattern https://regex101.com/r/rzUcJ4/1
var pattern = /^(\d{1,3}\.){3}\d{1,3}(:\d{1,5})?(\/.*)?$/;
var pattern = /^(\d{1,3}\.){3}\d{1,3}(:\d{1,5})?(\/([a-z0-9\-._~:\/\?#\[\]@!$&'\(\)\*\+,;=%]+)?)?$/;
function default_1(str) {
if (!pattern.test(str))
return false;
Expand Down
6 changes: 2 additions & 4 deletions dist-node/transform/identify.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var lists_1 = require("../lists");
var hasprotocol_1 = require("../tests/hasprotocol");
var email_1 = require("../tests/email");
var hasprotocol_1 = require("../tests/hasprotocol");
var lists_1 = require("../lists");
var ip_1 = require("../tests/ip");
var url_1 = require("../tests/url");
function default_1(inputArr, options) {
Expand Down Expand Up @@ -55,8 +55,6 @@ function default_1(inputArr, options) {
if (!urlObj)
return fragment;
else {
var past = index - 1;
var skip = false;
if ((inputArr[index - 1] === "'" || inputArr[index - 1] === '"') && ~lists_1.htmlAttrs.indexOf(inputArr[index - 2]))
return fragment;
return urlObj;
Expand Down
4 changes: 2 additions & 2 deletions dist-node/transform/transform.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { URLObj as URLObj } from "../util";
import { Options as Options } from "../util";
import { Options } from "../util";
import { URLObj } from "../util";
export default function (str: any, options: Options): string | Array<URLObj>;
6 changes: 3 additions & 3 deletions dist-node/transform/transform.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var separate_1 = require("../separate/separate");
var separate_2 = require("../separate/separate");
var identify_1 = require("./identify");
var separate_2 = require("../separate/separate");
function default_1(str, options) {
var arr = separate_1.separate(str);
var arr = separate_2.separate(str);
var identified = identify_1.default(arr, options);
// return the current list (with words being filtered out)
if (options.list) {
Expand All @@ -23,7 +23,7 @@ function default_1(str, options) {
return url2tag(fragment, options);
});
// join and return
return separate_2.deSeparate(identified);
return separate_1.deSeparate(identified);
}
exports.default = default_1;
function url2tag(fragment, options) {
Expand Down
22 changes: 10 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<!DOCTYPE html>
<html lang="en">
<head>
Expand All @@ -13,7 +12,6 @@
<![endif]-->

<link href="./assets/style.min.css" rel="stylesheet">

<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.3.0/bootbox.min.js"></script>
Expand Down Expand Up @@ -52,7 +50,7 @@
<div class="bs-docs-masthead" id="content" style="background: linear-gradient(135deg, #673AB7, #3F51B5);">
<div class="container">
<h1 class="home-title">Anchorme</h1>
<p class="lead" style='font-size:18px;margin-top:25px'>Tiny, fast, efficient, feature rich Javascript library to detect links / URLs / Emails in text and convert them to clickable HTML anchor links</p>
<p class="lead" style="font-size:18px;margin-top:25px">Tiny, fast, efficient, feature rich Javascript library to detect links / URLs / Emails in text and convert them to clickable HTML anchor links</p>
<p class="lead">
<a data-bootbox="download-popup" data-bootbox-size="large" class="btn btn-outline-inverse btn-lg">Download</a>
</p>
Expand Down Expand Up @@ -234,7 +232,7 @@ <h3 id="truncation">Truncation</h3>
</code></pre>

<p><b>JSFiddle Demo</b></p>
<script async src="//jsfiddle.net/alexcorvi/fouwnjkx/1/embed/js,result/"></script>
<script async src="//jsfiddle.net/alexcorvi/fouwnjkx/2/embed/js,result/"></script>


<hr>
Expand Down Expand Up @@ -276,7 +274,7 @@ <h3 id="adding-attributes">Adding attributes</h3>
function(urlObj){
if(urlObj.protocol !== "mailto:") return {name:"target",value:"blank"};
// following conditions can also be used:
// if(urlObj.raw.indexOf("@") > 0) return {name:"target",value:"blank"};
// if(urlObj.raw.indexOf("@") &gt; 0) return {name:"target",value:"blank"};
// if(urlObj.reason !== "email") return {name:"target",value:"blank"};
}
]
Expand All @@ -299,7 +297,7 @@ <h3 id="adding-attributes">Adding attributes</h3>
// the link (without any modification)
raw: "a@b.co",
// the encoded version of the link
// i.e. non-Latin characters -> URI encoding
// i.e. non-Latin characters -&gt; URI encoding
// also doesn't have a protocol (if it came with any)
encoded: "a@b.co",
}
Expand All @@ -309,7 +307,7 @@ <h3 id="adding-attributes">Adding attributes</h3>


<p><b>JSFiddle Demo</b></p>
<script async src="//jsfiddle.net/alexcorvi/y1qL2gmc/2/embed/js,result/"></script>
<script async src="//jsfiddle.net/alexcorvi/y1qL2gmc/4/embed/js,result/"></script>

<hr>
<h3 id="default-protocol">Default protocol</h3>
Expand Down Expand Up @@ -345,7 +343,7 @@ <h3 id="default-protocol">Default protocol</h3>
anchorme(string,{
defaultProtocol:function(url){
// where url is like: "www.google.com"
if(url.indexOf("google") > 0) return "https://";
if(url.indexOf("google") &gt; 0) return "https://";
else return "http://";
},
});
Expand All @@ -356,7 +354,7 @@ <h3 id="default-protocol">Default protocol</h3>
</p>

<p><b>JSFiddle Demo</b></p>
<script async src="//jsfiddle.net/alexcorvi/fu0k9ata/embed/js,result/"></script>
<script async src="//jsfiddle.net/alexcorvi/fu0k9ata/1/embed/js,result/"></script>

<hr>
<h3 id="excluding">Excluding</h3>
Expand Down Expand Up @@ -404,7 +402,7 @@ <h3 id="excluding">Excluding</h3>
</code></pre>

<p><b>JSFiddle Demo</b></p>
<script async src="//jsfiddle.net/alexcorvi/gydnngrz/embed/js,result/"></script>
<script async src="//jsfiddle.net/alexcorvi/gydnngrz/1/embed/js,result/"></script>

</section>
<section class="bs-docs-section">
Expand All @@ -429,7 +427,7 @@ <h3 id="validation">Validation</h3>
</code></pre>

<p><b>JSFiddle Demo:</b></p>
<script async src="//jsfiddle.net/alexcorvi/L0dex4q9/embed/js,result/"></script>
<script async src="//jsfiddle.net/alexcorvi/L0dex4q9/1/embed/js,result/"></script>

<hr>
<h3 id="listing">Listing</h3>
Expand All @@ -444,7 +442,7 @@ <h3 id="listing">Listing</h3>
</code></pre>

<p><b>JSFiddle Demo:</b></p>
<script async src="//jsfiddle.net/alexcorvi/z3g3haL1/embed/js,result/"></script>
<script async src="//jsfiddle.net/alexcorvi/z3g3haL1/1/embed/js,result/"></script>

</section>
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "anchorme",
"version": "1.0.1",
"version": "1.0.2",
"description": "A library to convert URLs to a clickable HTML anchor elements",
"main": "./dist-node/index.js",
"types": "./dist-node/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/lists.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/tests/ip.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {isPort as isPort} from "../util";
import {isPort} from "../util";

// general IP pattern https://regex101.com/r/rzUcJ4/1
const pattern = /^(\d{1,3}\.){3}\d{1,3}(:\d{1,5})?(\/.*)?$/;
const pattern = /^(\d{1,3}\.){3}\d{1,3}(:\d{1,5})?(\/([a-z0-9\-._~:\/\?#\[\]@!$&'\(\)\*\+,;=%]+)?)?$/;

export default function (str:string):boolean {

Expand Down
10 changes: 4 additions & 6 deletions src/transform/identify.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {htmlAttrs as htmlAttrs} from "../lists";
import hasProtocol from "../tests/hasprotocol";
import {Options} from "../util";
import {URLObj} from "../util";
import emailChecker from "../tests/email";
import hasProtocol from "../tests/hasprotocol";
import {htmlAttrs} from "../lists";
import ipChecker from "../tests/ip";
import urlChecker from "../tests/url";
import {Options} from "../util";
import {URLObj} from "../util";

export default function (inputArr:Array<string>, options:Options) {
return inputArr.map((fragment,index)=>{
Expand Down Expand Up @@ -65,8 +65,6 @@ export default function (inputArr:Array<string>, options:Options) {

if(!urlObj) return fragment;
else {
var past = index-1;
var skip = false;
if((inputArr[index-1] === "'" || inputArr[index-1] === '"') && ~htmlAttrs.indexOf(inputArr[index-2]))
return fragment;
return urlObj;
Expand Down
9 changes: 4 additions & 5 deletions src/transform/transform.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"use strict";
import {separate as separate} from "../separate/separate";
import {deSeparate as deSeparate} from "../separate/separate";
import {URLObj as URLObj} from "../util";
import {Options as Options} from "../util";
import {Options} from "../util";
import {URLObj} from "../util";
import {deSeparate} from "../separate/separate";
import identify from "./identify";
import {separate} from "../separate/separate";

export default function(str,options:Options):string|Array<URLObj>{

Expand Down

0 comments on commit cea5593

Please sign in to comment.