Yetangitu / bs

MIT License
16 stars 6 forks source link

extra character "/" in url for docs|search|recycle-bin api endpoints #3

Open dvankevich opened 1 year ago

dvankevich commented 1 year ago

My BookStack version v22.11.1

when i run command ./bs_orig search -q time

i got 301 Moved Permanently html response

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://192.168.56.142/api/search?query=time">here</a>.</p>
<hr>
<address>Apache/2.4.52 (Ubuntu) Server at 192.168.56.142 Port 80</address>
</body></html>

the reason is an extra character / in the url

must be http://192.168.56.142/api/search?query=time and there are http://192.168.56.142/api/search/?query=time

my little fix solves this problem

diff bs_orig bs
527,528c527,534
< 
<     "$curl" "${curl_options[@]}" --request GET --url "$url/api/$endpoint${id:+/}$id${target:+/}$target"
---
>     case $endpoint in
>         docs|search|recycle-bin)
>             "$curl" "${curl_options[@]}" --request GET --url "$url/api/$endpoint$id${target:+/}$target"
>             ;;
>         *)
>             "$curl" "${curl_options[@]}" --request GET --url "$url/api/$endpoint${id:+/}$id${target:+/}$target"
>             ;;
>     esac
PinkFreud commented 5 days ago

I've fixed this in my fork, and created a PR in this repo to have it merged. It looks like this repo might be abandoned, so I'm not holding my breath for it to be applied, but perhaps I'll be surprised.

https://github.com/Yetangitu/bs/pull/6