* Do path joins more safely
* Improve path cleaning and tests
* Lower-case error message
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* Correct handle potential errors in `get_path`
* Use `expect` in tests, rather than `unwrap`
* Correctly handle invalid upload path without panic
* Correctly handle filesystem create errors
* Use result rather than option to allow easier error handling
---------
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* feat(server): add url encoding
- Introduced an option to enable encoding for filenames in the returned URL.
- Modified the encoding approach to specifically target whitespaces, replacing them with `%20`.
- Included unit tests to validate this encoding approach.
- Added fixture tests for broader functional verification.
- Removed the `urlencoding` dependency from `Cargo.toml`.
* Refactor code and fixtures for better compliance and consistency
- Fixed errors in the fixture configuration to ensure tests run as expected.
- Reformatted line endings for consistency across the codebase.
- Made necessary adjustments to adhere to Clippy's recommendations.
* Enhance whitespace handling options for filenames
- Implemented a configuration choice for space handling in filenames: encode, replace with underscores or none.
- Added corresponding unit and fixture tests.
* Remove redundant function call
Fixed misplaced line as per @tessus's review feedback, preventing duplicate handling of spaces in filenames.
* Delete test file with spaces.txt
* Refactor filename space handling
- Introduced `SpaceHandling` enum to manage filename spaces.
- Updated server.rs and paste.rs to utilize the new method.
- Added unit tests for the new filename handling method.
- Adjusted fixture tests to reflect these changes.
* Move filename processing into `SpaceHandling` enum
- Relocated filename processing logic to reside within the `SpaceHandling` enum, enhancing encapsulation.
- Updated calls in `server.rs` and `paste.rs` to use the new method structure.
- Adjusted unit tests to align with the refactored function location and call pattern.
* Refactor based on review suggestions
- Incorporated the inline suggestions made by @tessus, removing the unnecessary one-line assignments.
- Ensured the code adheres to Rust guidelines by running clippy and fmt.
* chore(deps): revert changes in Cargo.lock
* chore(config): replace spaces as default
* refactor(config): move SpaceHandling to config module
---------
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
* add random suffix mode
* fix linter issues
* add test case
* fix linter issues
* add comments, remove empty lines and single line declarations
* more test cases
* refactor(config): rename suffix_mode to random_suffix
* refactor(paste): clean up the random suffix logic
* chore(config): add random suffix example to default config
* docs(readme): mention random suffix feature
* test(fixtures): add fixture test for random suffix mode
* random_suffix -> suffix_mode
* fix default extension for .dotfile w/o extension
* fix formatting
* style(format): fix the indentation for random suffix fixture
---------
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>