Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zys8119/axios-keywords
axios敏感词检测
https://github.com/zys8119/axios-keywords
Last synced: 10 days ago
JSON representation
axios敏感词检测
- Host: GitHub
- URL: https://github.com/zys8119/axios-keywords
- Owner: zys8119
- Created: 2022-01-09T06:10:54.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-09T08:14:15.000Z (almost 3 years ago)
- Last Synced: 2024-04-27T01:03:34.401Z (7 months ago)
- Language: TypeScript
- Size: 99.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# axios-keywords
axios敏感词检测
## 安装
`npm i axios-keywords -S`
## 引用
```typescript
import {create} from "axios";
import axiosKeywords from "axios-keywords";
const service = create();
service.interceptors.request.use((config) => {
return axiosKeywords(config, options)
})
```## 案例
```typescript
import axiosKeywords from "axios-keywords";
axiosKeywords(config, {
data:{
// ....
},
axiosConfig:{
url:"/api",
method:"get",
// ...
},
axiosConfigCode:0,
keywords:["敏感关键词组", "******"],
keywordsDetection:true,
keywordsRules:[
(wordsMap, config)=>{
if(!Object.values(wordsMap).some(v=>/^[0-9]*$/.test(v))){
return Promise.resolve();
}
return Promise.reject("提交的内容禁止全部数字")
},
// ...
],
errorMessage:"获取敏感词失败!",
customMessage:(swhResult)=>`请求失败,系统自动检测的您提交的内容包含【${swhResult.filter.join("、")}】等敏感字样,禁止提交`,
urlWhitelist:[
/url_keywords/,
// ...
]
})
```