Skip to content

Commit 6dbf3b5

Browse files
committed
docs(api): wrap URL by quotes in example
Some special chars in URL like `&` and `?` are also special chars in shell. Quote them to remove special meaning for shell. ```sh sed -i -E -e "/^(curl|wget)/s/http:[^ ]+/'&'/" doc/*/api.md ```
1 parent fa881f3 commit 6dbf3b5

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

doc/en-US/api.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Directory sort:
2222

2323
Example:
2424
```sh
25-
curl http://localhost/ghfs/
26-
curl http://localhost/ghfs/?sort=/T
25+
curl 'http://localhost/ghfs/'
26+
curl 'http://localhost/ghfs/?sort=/T'
2727
```
2828

2929
# Get JSON data of specified path
@@ -33,7 +33,7 @@ GET <path>?json[&sort=key]
3333

3434
Example:
3535
```sh
36-
curl http://localhost/ghfs/?json
36+
curl 'http://localhost/ghfs/?json'
3737
```
3838

3939
# Render page for downloading
@@ -47,7 +47,7 @@ It's convenient for tools like "wget" to download files recursively.
4747

4848
Example:
4949
```shell
50-
wget --recursive -nc -nH -np http://localhost/dir/?download
50+
wget --recursive -nc -nH -np 'http://localhost/dir/?download'
5151
```
5252

5353
# Download a file
@@ -58,7 +58,7 @@ GET <path/to/file>?download
5858

5959
Example:
6060
```sh
61-
curl http://localhost/ghfs/file?download
61+
curl 'http://localhost/ghfs/file?download'
6262
```
6363

6464
# Get contents of specified path as archive file
@@ -74,7 +74,7 @@ POST <path>?zip
7474

7575
Example:
7676
```sh
77-
curl http://localhost/tmp/?zip > tmp.zip
77+
curl 'http://localhost/tmp/?zip' > tmp.zip
7878
```
7979

8080
To archive specific sub items under current directory, pass `name` params:
@@ -92,7 +92,7 @@ name=<path1>&name=<path2>&...name=<pathN>
9292

9393
Example:
9494
```sh
95-
curl -X POST -d 'name=subdir1&name=subdir2/subdir21&name=file1&name=subdir3/file31' http://localhost/tmp/?zip > tmp.zip
95+
curl -X POST -d 'name=subdir1&name=subdir2/subdir21&name=file1&name=subdir3/file31' 'http://localhost/tmp/?zip' > tmp.zip
9696
```
9797

9898
# Create directories in specific path
@@ -108,7 +108,7 @@ name=<dir1path>&name=<dir2path>&...name=<dirNpath>
108108

109109
Example:
110110
```sh
111-
curl -X POST -d 'name=dir1&name=dir2&name=foo/bar/baz' http://localhost/tmp/?mkdir
111+
curl -X POST -d 'name=dir1&name=dir2&name=foo/bar/baz' 'http://localhost/tmp/?mkdir'
112112
```
113113

114114
# Upload files to specific path
@@ -122,20 +122,20 @@ POST <path>?upload[&json]
122122

123123
Example:
124124
```sh
125-
curl -F 'file=@file1.txt' -F 'file=@file2.txt;filename=renamed.txt' http://localhost/tmp/?upload
125+
curl -F 'file=@file1.txt' -F 'file=@file2.txt;filename=renamed.txt' 'http://localhost/tmp/?upload'
126126
```
127127

128128
If "mkdir" is also enabled, it is possible to upload file to a specific path relative to current URL path,
129129
using form name `dirfile` instead of `file`:
130130
```sh
131-
curl -F 'dirfile=@file1.txt;filename=subdir/childdir/filename.txt' http://localhost/tmp/?upload
131+
curl -F 'dirfile=@file1.txt;filename=subdir/childdir/filename.txt' 'http://localhost/tmp/?upload'
132132
# file is now available at http://localhost/tmp/subdir/childdir/filename.txt
133133
```
134134

135135
Another form name `innerdirfile` is similar to `dirfile`, but strip first level of upload directory.
136136
It is convenient to upload contents of a directory:
137137
```sh
138-
curl -F 'innerdirfile=@file1.txt;filename=subdir/childdir/filename.txt' http://localhost/tmp/?upload
138+
curl -F 'innerdirfile=@file1.txt;filename=subdir/childdir/filename.txt' 'http://localhost/tmp/?upload'
139139
# file is now available at http://localhost/tmp/childdir/filename.txt
140140
```
141141

@@ -153,5 +153,5 @@ name=<dir1>&name=<dir2>&...name=<dirN>
153153

154154
Example:
155155
```sh
156-
curl -X POST -d 'name=dir1&name=dir2&name=dir3' http://localhost/tmp/?delete
156+
curl -X POST -d 'name=dir1&name=dir2&name=dir3' 'http://localhost/tmp/?delete'
157157
```

doc/zh-CN/api.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ GET <path>[?sort=sortBy]
2222

2323
举例:
2424
```sh
25-
curl http://localhost/ghfs/
26-
curl http://localhost/ghfs/?sort=/T
25+
curl 'http://localhost/ghfs/'
26+
curl 'http://localhost/ghfs/?sort=/T'
2727
```
2828

2929
# 获取指定路径JSON形式的数据
@@ -33,7 +33,7 @@ GET <path>?json[&sort=key]
3333

3434
举例:
3535
```sh
36-
curl http://localhost/ghfs/?json
36+
curl 'http://localhost/ghfs/?json'
3737
```
3838

3939
# 显示用于下载的页面
@@ -45,7 +45,7 @@ GET <path>?download[&sort=key]
4545

4646
举例:
4747
```shell
48-
wget --recursive -nc -nH -np http://localhost/dir/?download
48+
wget --recursive -nc -nH -np 'http://localhost/dir/?download'
4949
```
5050

5151
# 下载文件
@@ -56,7 +56,7 @@ GET <path/to/file>?download
5656

5757
举例:
5858
```sh
59-
curl http://localhost/ghfs/file?download
59+
curl 'http://localhost/ghfs/file?download'
6060
```
6161

6262
# 以打包文件形式获取指定路径下的内容
@@ -72,7 +72,7 @@ POST <path>?zip
7272

7373
举例:
7474
```sh
75-
curl http://localhost/tmp/?zip > tmp.zip
75+
curl 'http://localhost/tmp/?zip' > tmp.zip
7676
```
7777

7878
要打包当前目录下的指定子项,用`name`参数指定:
@@ -90,7 +90,7 @@ name=<path1>&name=<path2>&...name=<pathN>
9090

9191
举例:
9292
```sh
93-
curl -X POST -d 'name=subdir1&name=subdir2/subdir21&name=file1&name=subdir3/file31' http://localhost/tmp/?zip > tmp.zip
93+
curl -X POST -d 'name=subdir1&name=subdir2/subdir21&name=file1&name=subdir3/file31' 'http://localhost/tmp/?zip' > tmp.zip
9494
```
9595

9696
# 在指定路径下创建目录
@@ -106,7 +106,7 @@ name=<dir1path>&name=<dir2path>&...name=<dirNpath>
106106

107107
举例:
108108
```sh
109-
curl -X POST -d 'name=dir1&name=dir2&name=foo/bar/baz' http://localhost/tmp/?mkdir
109+
curl -X POST -d 'name=dir1&name=dir2&name=foo/bar/baz' 'http://localhost/tmp/?mkdir'
110110
```
111111

112112
# 上传文件到指定路径
@@ -120,20 +120,20 @@ POST <path>?upload[&json]
120120

121121
举例:
122122
```sh
123-
curl -F 'file=@file1.txt' -F 'file=@file2.txt;filename=renamed.txt' http://localhost/tmp/?upload
123+
curl -F 'file=@file1.txt' -F 'file=@file2.txt;filename=renamed.txt' 'http://localhost/tmp/?upload'
124124
```
125125

126126
如果还启用了“mkdir”选项,可以将文件上传到相对于当前URL路径的特定路径,
127127
使用表单字段`dirfile`代替`file`
128128
```sh
129-
curl -F 'dirfile=@file1.txt;filename=subdir/childdir/filename.txt' http://localhost/tmp/?upload
129+
curl -F 'dirfile=@file1.txt;filename=subdir/childdir/filename.txt' 'http://localhost/tmp/?upload'
130130
# 文件现在位于 http://localhost/tmp/subdir/childdir/filename.txt
131131
```
132132

133133
另一表单字段`innerdirfile``dirfile`很相似,只是会去除第一级上传目录。
134134
这对于上传一个目录中的内容很方便:
135135
```sh
136-
curl -F 'innerdirfile=@file1.txt;filename=subdir/childdir/filename.txt' http://localhost/tmp/?upload
136+
curl -F 'innerdirfile=@file1.txt;filename=subdir/childdir/filename.txt' 'http://localhost/tmp/?upload'
137137
# 文件现在位于 http://localhost/tmp/childdir/filename.txt
138138
```
139139

@@ -151,5 +151,5 @@ name=<dir1>&name=<dir2>&...name=<dirN>
151151

152152
举例:
153153
```sh
154-
curl -X POST -d 'name=dir1&name=dir2&name=dir3' http://localhost/tmp/?delete
154+
curl -X POST -d 'name=dir1&name=dir2&name=dir3' 'http://localhost/tmp/?delete'
155155
```

0 commit comments

Comments
 (0)