Skip to content

Commit

Permalink
docs(api): wrap URL by quotes in example
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
marjune163 committed Jul 28, 2021
1 parent fa881f3 commit 6dbf3b5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
24 changes: 12 additions & 12 deletions doc/en-US/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Directory sort:

Example:
```sh
curl http://localhost/ghfs/
curl http://localhost/ghfs/?sort=/T
curl 'http://localhost/ghfs/'
curl 'http://localhost/ghfs/?sort=/T'
```

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

Example:
```sh
curl http://localhost/ghfs/?json
curl 'http://localhost/ghfs/?json'
```

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

Example:
```shell
wget --recursive -nc -nH -np http://localhost/dir/?download
wget --recursive -nc -nH -np 'http://localhost/dir/?download'
```

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

Example:
```sh
curl http://localhost/ghfs/file?download
curl 'http://localhost/ghfs/file?download'
```

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

Example:
```sh
curl http://localhost/tmp/?zip > tmp.zip
curl 'http://localhost/tmp/?zip' > tmp.zip
```

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

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

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

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

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

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

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

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

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

Example:
```sh
curl -X POST -d 'name=dir1&name=dir2&name=dir3' http://localhost/tmp/?delete
curl -X POST -d 'name=dir1&name=dir2&name=dir3' 'http://localhost/tmp/?delete'
```
24 changes: 12 additions & 12 deletions doc/zh-CN/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ GET <path>[?sort=sortBy]

举例:
```sh
curl http://localhost/ghfs/
curl http://localhost/ghfs/?sort=/T
curl 'http://localhost/ghfs/'
curl 'http://localhost/ghfs/?sort=/T'
```

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

举例:
```sh
curl http://localhost/ghfs/?json
curl 'http://localhost/ghfs/?json'
```

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

举例:
```shell
wget --recursive -nc -nH -np http://localhost/dir/?download
wget --recursive -nc -nH -np 'http://localhost/dir/?download'
```

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

举例:
```sh
curl http://localhost/ghfs/file?download
curl 'http://localhost/ghfs/file?download'
```

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

举例:
```sh
curl http://localhost/tmp/?zip > tmp.zip
curl 'http://localhost/tmp/?zip' > tmp.zip
```

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

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

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

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

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

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

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

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

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

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

0 comments on commit 6dbf3b5

Please sign in to comment.