link.js 350 B

12345678910111213141516
  1. 'use strict';
  2. module.exports = locate;
  3. function locate(value, fromIndex) {
  4. var link = value.indexOf('[', fromIndex);
  5. var image = value.indexOf('![', fromIndex);
  6. if (image === -1) {
  7. return link;
  8. }
  9. /* Link can never be `-1` if an image is found, so we don’t need
  10. * to check for that :) */
  11. return link < image ? link : image;
  12. }