You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

24 lines
499 B

/**
* @author Titus Wormer
* @copyright 2015 Titus Wormer
* @license MIT
* @module remark:parse:locate:link
* @fileoverview Locate a link.
*/
'use strict';
module.exports = locate;
function locate(value, fromIndex) {
var link = value.indexOf('[', fromIndex);
var image = value.indexOf('![', fromIndex);
if (image === -1) {
return link;
}
/* Link can never be `-1` if an image is found, so we don’t need
* to check for that :) */
return link < image ? link : image;
}