0.1.10 • Published 3 years ago

r3x v0.1.10

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

r3x.js NPM Package Build Size NPM Downloads Dev Dependencies

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 r3x

OR

yarn add r3x

Download

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

targettextto html
urlwww.mydomain.com<a href="https://www.mydomain.com" target="_blank">https://www.mydomain.com</a>
urlhttp://www.mydomain.ch<a href="http://www.mydomain.ch" target="_blank">http://www.mydomain.ch</a>
urlwww.mydomain.co.jp<a href="https://www.mydomain.co.jp" target="_blank">www.mydomain.co.jp</a>
urlhttp://mydomain.com<a href="http://mydomain.com" target="_blank">http://mydomain.com</a>
ipv4127.0.0.1<a href="https://127.0.0.1" target="_blank">127.0.0.1</a>
ipv49.255.255.255<a href="https://9.255.255.255" target="_blank">9.255.255.255</a>
ipv61200: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 files100100100100
LinkFormatter.js100100100100
TagsStripper.js100100100100

©️ License

Copyright ©️ 2020 monsieurbadia

Released under the MIT license

Contributors

Logo - @mllemartins

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago