-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00c6803
commit c76fea7
Showing
21 changed files
with
337 additions
and
150 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
"use strict"; | ||
|
||
var _ = require('lodash'), | ||
url = require('url'), | ||
doiRegex = require("doi-regex"), | ||
Autolinker = require('autolinker'), | ||
linkTemplateTarget = '<a href="%s1" target="%s2">%s3</a>', | ||
|
@@ -48,6 +49,16 @@ function linkify(text, options) { | |
return Autolinker.link(text, newOptions); | ||
} | ||
|
||
function reduceUrlToDomain(text) { | ||
if (_.isString(text)) { | ||
var parsedUrl = url.parse(text), | ||
domain = parsedUrl.hostname; | ||
return domain; | ||
} else { | ||
return ''; | ||
} | ||
} | ||
|
||
|
||
function getDOILink(text, throwOnMissing) { | ||
var doi; | ||
|
@@ -83,7 +94,8 @@ module.exports = { | |
insertLinks: insertLinks, | ||
linkify: linkify, | ||
getDOILink: getDOILink, | ||
readableDOI: readableDOI | ||
readableDOI: readableDOI, | ||
reduceUrlToDomain: reduceUrlToDomain | ||
}; | ||
|
||
//console.log(linkify('replace this [email protected] and this one [email protected] and show a link to http://mysite.com but not to relative ones like this /occurrence/234')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.