Skip to content

git-ced/solid-links

Repository files navigation

solid-links

Transform URLs in strings to actual links. It will find valid links in the given string and create <a> tags for it.

Internally, it uses this Regex to identify links.

NPM npm bundle size (scoped) npm bundle size (scoped version) Libraries.io dependency status for latest release, scoped npm package NPM

Table of Contents

Installation

This library is available through the npm registry.

NPM

$ npm -i solid-links

Yarn

$ yarn add solid-links

Setup

Start using it by importing the library first.

CommonJS

const Linkify = require('solid-links');

or

ES6

import Linkify from 'solid-links';

Usage

import Linkify from 'solid-links';

const TEST_STRING = `
  Will match the following cases

      http://www.foufos.gr
      https://www.foufos.gr
      http://foufos.gr
      http://www.foufos.gr/kino
      http://werer.gr
      www.foufos.gr
      www.mp3.com
      www.t.co
      http://t.co
      http://www.t.co
      https://www.t.co
      www.aa.com
      http://aa.com
      http://www.aa.com
      https://www.aa.com

  Will NOT match the following

      www.foufos
      www.foufos-.gr
      www.-foufos.gr
      foufos.gr
      http://www.foufos
      http://foufos
      www.mp3#.com
`;

export default function Sample() {
  return (
    <Linkify
      text={TEST_STRING}
      style="text-decoration: underline; color: blue;"
    />
  );
}

Authors

See also the list of contributors who participated in this project.

Changelog

Changelog

License

MIT

About

Transform URLs in strings to actual links.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published