-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): add random suffix mode (#69)
* 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 <[email protected]>
- Loading branch information
Showing
8 changed files
with
146 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,19 @@ content="test data" | |
|
||
setup() { | ||
echo "$content" > file | ||
echo "$content" > .file | ||
} | ||
|
||
run_test() { | ||
file_url=$(curl -s -F "file=@file" localhost:8000) | ||
test "$file_url" = "http://localhost:8000/file.txt" | ||
test "$content" = "$(cat upload/file.txt)" | ||
test "$content" = "$(curl -s $file_url)" | ||
file_url2=$(curl -s -F "[email protected]" localhost:8000) | ||
test "$file_url2" = "http://localhost:8000/.file.txt" | ||
} | ||
|
||
teardown() { | ||
rm file | ||
rm file .file | ||
rm -r upload | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[server] | ||
address = "127.0.0.1:8000" | ||
max_content_length = "10MB" | ||
upload_path = "./upload" | ||
|
||
[paste] | ||
random_url = { enabled = true, type = "alphanumeric", length = "6", suffix_mode = true } | ||
default_extension = "txt" | ||
duplicate_files = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
content="test data" | ||
|
||
setup() { | ||
echo "$content" >file | ||
} | ||
|
||
run_test() { | ||
first_file_url=$(curl -s -F "file=@file" localhost:8000) | ||
test "$first_file_url" != "http://localhost:8000/file.txt" | ||
test "$content" = "$(curl -s $first_file_url)" | ||
|
||
second_file_url=$(curl -s -F "file=@file" localhost:8000) | ||
test "$first_file_url" != "http://localhost:8000/file.txt" | ||
test "$content" = "$(curl -s $first_file_url)" | ||
|
||
test "$first_file_url" != "$second_file_url" | ||
|
||
test "$(cat upload/${first_file_url/http:\/\/localhost:8000\//})" \ | ||
= "$(cat upload/${second_file_url/http:\/\/localhost:8000\//})" | ||
|
||
[[ $(find upload/ -name "file.*.txt" -print -quit 2>/dev/null) ]] || exit 1 | ||
} | ||
|
||
teardown() { | ||
rm file | ||
rm -r upload | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters