mirror of
https://github.com/YunoHost-Apps/baikal_ynh.git
synced 2024-09-03 18:16:11 +02:00
Rewrite is_url_handled
A simpler version of the helper, without the array and with more comments.
This commit is contained in:
parent
7d2d0cdbb1
commit
1057d7150c
1 changed files with 22 additions and 1 deletions
|
@ -25,6 +25,27 @@ is_url_handled_custom() {
|
||||||
#[[ ! ${output[0]} =~ \/yunohost\/sso\/ ]]
|
#[[ ! ${output[0]} =~ \/yunohost\/sso\/ ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_url_handled_rewrited() {
|
||||||
|
local url="$1"
|
||||||
|
# Try to get the url with curl, and keep the http code and an eventual redirection url.
|
||||||
|
local curl_output="$(curl --insecure --silent --output /dev/null \
|
||||||
|
--write-out '%{http_code};%{redirect_url}' "$url")"
|
||||||
|
|
||||||
|
# Cut the output and keep only the first part to keep the http code
|
||||||
|
local http_code="${curl_output%%;*}"
|
||||||
|
# Do the same thing but keep the second part, the redirection url
|
||||||
|
local redirection="${curl_output#*;}"
|
||||||
|
|
||||||
|
# Return 1 if the url isn't handled.
|
||||||
|
# Return 1 if the url has returned 404
|
||||||
|
if [ "$http_code" = "404" ]; then
|
||||||
|
return 1
|
||||||
|
# Return 1 if the url is redirected to the SSO
|
||||||
|
elif [[ $redirection =~ "/yunohost/sso" ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# ============= FUTURE YUNOHOST HELPER =============
|
# ============= FUTURE YUNOHOST HELPER =============
|
||||||
# Delete a file checksum from the app settings
|
# Delete a file checksum from the app settings
|
||||||
#
|
#
|
||||||
|
@ -35,4 +56,4 @@ is_url_handled_custom() {
|
||||||
ynh_delete_file_checksum () {
|
ynh_delete_file_checksum () {
|
||||||
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||||
ynh_app_setting_delete $app $checksum_setting_name
|
ynh_app_setting_delete $app $checksum_setting_name
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue