|
1 | | -# React + TypeScript + Vite |
2 | | - |
3 | | -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. |
4 | | - |
5 | | -Currently, two official plugins are available: |
6 | | - |
7 | | -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh |
8 | | -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh |
9 | | - |
10 | | -## Expanding the ESLint configuration |
11 | | - |
12 | | -If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: |
13 | | - |
14 | | -```js |
15 | | -export default tseslint.config([ |
16 | | - globalIgnores(['dist']), |
17 | | - { |
18 | | - files: ['**/*.{ts,tsx}'], |
19 | | - extends: [ |
20 | | - // Other configs... |
21 | | - |
22 | | - // Remove tseslint.configs.recommended and replace with this |
23 | | - ...tseslint.configs.recommendedTypeChecked, |
24 | | - // Alternatively, use this for stricter rules |
25 | | - ...tseslint.configs.strictTypeChecked, |
26 | | - // Optionally, add this for stylistic rules |
27 | | - ...tseslint.configs.stylisticTypeChecked, |
28 | | - |
29 | | - // Other configs... |
30 | | - ], |
31 | | - languageOptions: { |
32 | | - parserOptions: { |
33 | | - project: ['./tsconfig.node.json', './tsconfig.app.json'], |
34 | | - tsconfigRootDir: import.meta.dirname, |
35 | | - }, |
36 | | - // other options... |
37 | | - }, |
38 | | - }, |
39 | | -]) |
| 1 | +# cURL Filter |
| 2 | + |
| 3 | +[中文文档](README.zh-CN.md) | English |
| 4 | + |
| 5 | +A powerful web-based tool for filtering and editing cURL commands with configurable rules. Perfect for cleaning up cURL commands copied from browser developer tools before importing them into external systems. |
| 6 | + |
| 7 | +## 🚀 Live Demo |
| 8 | + |
| 9 | +Visit: [https://jsrei.github.io/curl-filter/](https://jsrei.github.io/curl-filter/) |
| 10 | + |
| 11 | +## 🎯 Problem Solved |
| 12 | + |
| 13 | +When you copy a request as cURL from Chrome DevTools (or other browsers), it includes many default headers and parameters that you might not need: |
| 14 | + |
| 15 | +- Unnecessary headers like `User-Agent`, `Accept-Language`, `Accept-Encoding`, etc. |
| 16 | +- Browser-specific headers like `sec-ch-ua`, `sec-fetch-*` headers |
| 17 | +- Authentication cookies that shouldn't be shared |
| 18 | +- Redundant query parameters |
| 19 | + |
| 20 | +This tool helps you clean up these cURL commands by applying configurable filtering rules. |
| 21 | + |
| 22 | +## 🔧 Use Cases |
| 23 | + |
| 24 | +- **API Testing Tools**: Clean cURL commands before importing into Postman, Apifox, Insomnia |
| 25 | +- **Coze Plugin Development**: Prepare clean API requests for plugin configuration |
| 26 | +- **Documentation**: Generate clean cURL examples for API documentation |
| 27 | +- **Security**: Remove sensitive headers and cookies from shared cURL commands |
| 28 | +- **Automation**: Standardize cURL commands for scripts and CI/CD pipelines |
| 29 | + |
| 30 | +## ✨ Features |
| 31 | + |
| 32 | +- **Smart Filtering**: Remove unwanted headers, query parameters, and form data |
| 33 | +- **Configurable Rules**: Create custom filtering rules with regex patterns |
| 34 | +- **Real-time Preview**: See filtering results as you type |
| 35 | +- **History Management**: Keep track of your filtering history |
| 36 | +- **Export/Import**: Save and share your filtering rules |
| 37 | +- **Responsive Design**: Works on desktop and mobile devices |
| 38 | + |
| 39 | +## 🛠️ Installation |
| 40 | + |
| 41 | +### Prerequisites |
| 42 | + |
| 43 | +- Node.js 18+ |
| 44 | +- npm or yarn |
| 45 | + |
| 46 | +### Local Development |
| 47 | + |
| 48 | +1. Clone the repository: |
| 49 | +```bash |
| 50 | +git clone https://github.com/JSREI/curl-filter.git |
| 51 | +cd curl-filter |
| 52 | +``` |
| 53 | + |
| 54 | +2. Install dependencies: |
| 55 | +```bash |
| 56 | +npm install |
| 57 | +``` |
| 58 | + |
| 59 | +3. Start the development server: |
| 60 | +```bash |
| 61 | +npm run dev |
| 62 | +# or use the provided script |
| 63 | +./start.sh |
40 | 64 | ``` |
41 | 65 |
|
42 | | -You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: |
43 | | - |
44 | | -```js |
45 | | -// eslint.config.js |
46 | | -import reactX from 'eslint-plugin-react-x' |
47 | | -import reactDom from 'eslint-plugin-react-dom' |
48 | | - |
49 | | -export default tseslint.config([ |
50 | | - globalIgnores(['dist']), |
51 | | - { |
52 | | - files: ['**/*.{ts,tsx}'], |
53 | | - extends: [ |
54 | | - // Other configs... |
55 | | - // Enable lint rules for React |
56 | | - reactX.configs['recommended-typescript'], |
57 | | - // Enable lint rules for React DOM |
58 | | - reactDom.configs.recommended, |
59 | | - ], |
60 | | - languageOptions: { |
61 | | - parserOptions: { |
62 | | - project: ['./tsconfig.node.json', './tsconfig.app.json'], |
63 | | - tsconfigRootDir: import.meta.dirname, |
64 | | - }, |
65 | | - // other options... |
66 | | - }, |
67 | | - }, |
68 | | -]) |
| 66 | +4. Open your browser and visit `http://localhost:25519` |
| 67 | + |
| 68 | +### Build for Production |
| 69 | + |
| 70 | +```bash |
| 71 | +npm run build |
69 | 72 | ``` |
| 73 | + |
| 74 | +The built files will be in the `dist` directory. |
| 75 | + |
| 76 | +## 📖 Usage |
| 77 | + |
| 78 | +1. **Paste cURL Command**: Copy a cURL command from your browser's developer tools and paste it into the input field. |
| 79 | + |
| 80 | +2. **Configure Rules**: Click "Rule Management" to set up filtering rules: |
| 81 | + - Remove specific headers (e.g., `User-Agent`, `Accept-Language`) |
| 82 | + - Filter query parameters |
| 83 | + - Clean form data |
| 84 | + - Remove JSON body fields |
| 85 | + |
| 86 | +3. **Apply Filters**: Click "Apply Filter Rules" to process your cURL command. |
| 87 | + |
| 88 | +4. **Copy Result**: Use the copy button to copy the cleaned cURL command. |
| 89 | + |
| 90 | +### Example |
| 91 | + |
| 92 | +**Before filtering:** |
| 93 | +```bash |
| 94 | +curl 'https://api.example.com/users?page=1' \ |
| 95 | + -H 'accept: application/json' \ |
| 96 | + -H 'accept-language: en-US,en;q=0.9,zh-CN;q=0.8' \ |
| 97 | + -H 'cache-control: no-cache' \ |
| 98 | + -H 'sec-ch-ua: "Chrome";v="120"' \ |
| 99 | + -H 'sec-fetch-dest: empty' \ |
| 100 | + -H 'user-agent: Mozilla/5.0...' |
| 101 | +``` |
| 102 | + |
| 103 | +**After filtering:** |
| 104 | +```bash |
| 105 | +curl 'https://api.example.com/users?page=1' \ |
| 106 | + -H 'accept: application/json' \ |
| 107 | + -H 'cache-control: no-cache' |
| 108 | +``` |
| 109 | + |
| 110 | +## 🔧 Configuration |
| 111 | + |
| 112 | +The tool supports various filtering rules: |
| 113 | + |
| 114 | +- **Header Filters**: Remove or modify HTTP headers |
| 115 | +- **Query Parameter Filters**: Clean URL parameters |
| 116 | +- **Form Data Filters**: Filter form fields |
| 117 | +- **JSON Body Filters**: Remove JSON properties |
| 118 | +- **Custom Patterns**: Use regex for advanced filtering |
| 119 | + |
| 120 | +## 🤝 Contributing |
| 121 | + |
| 122 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 123 | + |
| 124 | +1. Fork the repository |
| 125 | +2. Create your feature branch (`git checkout -b feature/AmazingFeature`) |
| 126 | +3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) |
| 127 | +4. Push to the branch (`git push origin feature/AmazingFeature`) |
| 128 | +5. Open a Pull Request |
| 129 | + |
| 130 | +## 📄 License |
| 131 | + |
| 132 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 133 | + |
| 134 | +## 🙏 Acknowledgments |
| 135 | + |
| 136 | +- Built with React, TypeScript, and Vite |
| 137 | +- UI components from Material-UI |
| 138 | +- Deployed on GitHub Pages |
| 139 | + |
| 140 | +## 📞 Support |
| 141 | + |
| 142 | +If you have any questions or need help, please: |
| 143 | + |
| 144 | +1. Check the [Issues](https://github.com/JSREI/curl-filter/issues) page |
| 145 | +2. Create a new issue if your problem isn't already reported |
| 146 | +3. Provide detailed information about your use case |
0 commit comments