https://github.com/lode/linkify
Finding and linkifying things that look like links
https://github.com/lode/linkify
javascript linkify multi-lingual php
Last synced: 7 months ago
JSON representation
Finding and linkifying things that look like links
- Host: GitHub
- URL: https://github.com/lode/linkify
- Owner: lode
- License: mit
- Created: 2014-06-03T12:18:31.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-06-17T07:04:48.000Z (over 9 years ago)
- Last Synced: 2025-01-30T05:26:27.138Z (8 months ago)
- Topics: javascript, linkify, multi-lingual, php
- Language: PHP
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Linkify
Finding and linkifying things that look like links.
It focuses on: a main use case, short and fast code, and code-sharing between backend and frontend.
This package works for multiple languages, right now php and js.
## Install
[Use Composer](http://getcomposer.org/). And use require to get the latest stable version:
```
composer require alsvanzelf/linkify:dev-master
```## Features
The basics:
- Anything that starts with `http://`, `https://` or `www.`
- No support for ftp, email addresses, basic auth, and other edge cases.
- No advanced validation, for example real tld's.
- Adds `http://` for the href when it was not given in the text.Things that work:
- Case insensitive
- Unicode
- Paths, query strings, hashes, and other allowed characters
- Urls starting/ending a line or the whole string
- Not including punctuation after the url
- Urls enclosed in brackets
- Urls with brackets inside the urlThings that -currently- do not work:
- Urls which contain one of: @ |
## Usage
``` php
$linkifier = new alsvanzelf\linkify\linkify();
$linkified = $linkifier->linkify($plain);
`````` js
var linkified = linkify(plain);
```Note the input string should NOT contain html to prevent XSS.
As afterwards one can not differentiate the added anchors from existing html.## Contribute
Pull Requests or issues are welcome!
For example on adding more languages, or perfecting the cases catched.
## License
[MIT](/LICENSE)
## Thanks
Thanks to inspiration from:
- http://blog.codinghorror.com/the-problem-with-urls/
- https://github.com/misd-service-development/php-linkify
- http://daringfireball.net/2010/07/improved_regex_for_matching_urls
- http://daringfireball.net/misc/2010/07/url-matching-regex-test-data.text
- https://mathiasbynens.be/demo/url-regex