0.1.10 • Published 5 years ago
r3x v0.1.10
r3x.js

cleanify ip addresses and html tags
a basic formatter for patterns that need to be modify or stripped as ipv4, ipv6, url or tag.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<title>r3x - examples</title>
<script src='./r3x.js'></script>
</head>
<body>
<script>
const { LinkFormatter, TagsStripper } = r3x;
// returns `<a href="127.0.0.1" target="_blank">127.0.0.1</a>`
const ipv4 = LinkFormatter.do("127.0.0.1", ['IPV4']).output;
// returns `<a href="2001:0620:0000:0000:0211:24FF:FE80:C12C" target="_blank">2001:0620:0000:0000:0211:24FF:FE80:C12C</a>`
const ipv6 = LinkFormatter.do("2001:0620:0000:0000:0211:24FF:FE80:C12C", ['IPV6']).output;
// returns `<a href="https://www.youtube.com/watch?v=id" target="_blank">https://www.youtube.com/watch?v=id</a>`
const url = LinkFormatter.do("https://www.youtube.com/watch?v=id", ['URL']).output;
// returns `<a href="9.255.255.255" target="_blank">9.255.255.255</a> <a href="1200:0000:AB00:1234:0000:2552:7777:1313" target="_blank">1200:0000:AB00:1234:0000:2552:7777:1313</a> <a href="https://www.youtube.com" target="_blank">https://www.youtube.com</a>`
const all = LinkFormatter.do("127.0.0.1 2001:0620:0000:0000:0211:24FF:FE80:C12C 2001:db8::8a2e:370:7334 https://www.youtube.com/watch?v=id", ['IPV4', 'IPV6', 'URL']).output;
// returns `alert("message.alert")`
const tag = TagsStripper.do(`<script>alert("message");</script>`).output;
console.log({ ipv4, ipv6, url, all, tag });
</script>
</body>
</html>📦 Install dependencies
Command line
npm i r3xOR
yarn add r3xDownload
You can also, download the repo, recover the file which is in out/r3x.js then free to you to place it in the place of your choice in your project.
🚀 Start project
import r3x from 'r3x';and there you go! you can start asking him what you want. take two minutes to find out how to use it.
overview
| target | text | to html |
|---|---|---|
| url | www.mydomain.com | <a href="https://www.mydomain.com" target="_blank">https://www.mydomain.com</a> |
| url | http://www.mydomain.ch | <a href="http://www.mydomain.ch" target="_blank">http://www.mydomain.ch</a> |
| url | www.mydomain.co.jp | <a href="https://www.mydomain.co.jp" target="_blank">www.mydomain.co.jp</a> |
| url | http://mydomain.com | <a href="http://mydomain.com" target="_blank">http://mydomain.com</a> |
| ipv4 | 127.0.0.1 | <a href="https://127.0.0.1" target="_blank">127.0.0.1</a> |
| ipv4 | 9.255.255.255 | <a href="https://9.255.255.255" target="_blank">9.255.255.255</a> |
| ipv6 | 1200:0000:AB00:1233:0000:2552:7777:1313 | <a href="https://1200:0000:AB00:1233:0000:2552:7777:1313" target="_blank">1200:0000:AB00:1233:0000:2552:7777:1313</a> |
🚨 Tests
Running
run the following command line: yarn test:watch
Coverage
run the following command line: yarn test:reports
| File | % Stmts | % Branch | % Funcs | % Lines |
|---|---|---|---|---|
| All files | 100 | 100 | 100 | 100 |
| LinkFormatter.js | 100 | 100 | 100 | 100 |
| TagsStripper.js | 100 | 100 | 100 | 100 |
©️ License
Copyright ©️ 2020 monsieurbadia
Released under the MIT license
Contributors
Logo - @mllemartins