Defang and refang IoC
npm install fanger
!Node.js CI


fanger is an npm package for defang and refang IoC.
Defang means to change a part of IoC to make inaccessible or unclickable. (e.g. example.com => example[.]com)
Refang means to revert a defanged IoC to the original one. (e.g. example[.]com => example.com)
``bash`
npm install fanger -g
`bash
$ echo "example.com" | defang
example[.]com
$ echo "test@example.com" | defang
test@example[.]com
$ echo "https://example.com" | defang
hxxps://example[.]com
`
`bash
$ echo "example[.]com" | refang
example.com
$ echo "test@example[.]com" | refang
test@example.com
$ echo "hxxps://example[.]com" | refang
https://example.com
`
#### As a library
`typescript
import { defang, refang } from "fanger";
const text = "example.com";
console.log(defang(text));
// example[.]com
const defangedText = "example[.]com";
console.log(refang(defangedText));
// example.com
`
The following defang techniques are supported.
#### IPv4
- 1.1.1.1 => 1[.]1.1.1
The first dot of an IPv4 will be replaced with [.].
#### Domain
- example.com => example[.]comtest.com.example.com
- => test[.]com.example[.]com
A dot before a label which is registered as a TLD will be replaced with [.].
#### HTTP scheme
- http => hxxphttps
- => hxxps
The following refang techniques are supported.
| Techniques | Defanged | Refanged |
|------------------|----------------------------------------|---------------------------------|
| Remove spaces | 1.1.1 . 1 | 1.1.1.1 |[.]
| => . | 1.1.1[.]1 | 1.1.1.1 |(.)
| => . | 1.1.1(.)1 | 1.1.1.1 |{.}
| => . | 1.1.1{.}1 | 1.1.1.1 |\.
| => . | example\.com | example.com |[/]
| => / | http://example.com[/]path | http://example.com/path |[:]
| => : | http[:]//example.com | http://example.com |[://]
| => :// | http[://]example.com | http://example.com |hxxp
| => http | hxxps://google.com | https://google.com |[at]
| => @ | test[at]example.com | test@example.com |[@]
| => @ | test[@]example.com | test@example.com |(@)
| => @ | test(@)example.com | test@example.com |[dot]
| => . | test@example[dot]com | test@example.com |(dot)
| => . | test@example(dot)com | test@example.com |{dot}
| => . | test@example{dot}com | test@example.com |1.1.1[.1
| Partial | | 1.1.1.1 |hxxps[:]//test\.example[.)com[/]path
| Any combination | | https://test.example.com/path` |