helpers 2.1: use positional args for ynh_normalize_url_path

This commit is contained in:
Alexandre Aubin 2024-05-27 22:50:00 +02:00
parent f895724a25
commit a240fb2316

View file

@ -112,8 +112,6 @@ ynh_sanitize_dbid() {
# Normalize the url path syntax # Normalize the url path syntax
# #
# [internal]
#
# Handle the slash at the beginning of path and its absence at ending # Handle the slash at the beginning of path and its absence at ending
# Return a normalized url path # Return a normalized url path
# #
@ -124,16 +122,11 @@ ynh_sanitize_dbid() {
# ynh_normalize_url_path /example/ # -> /example # ynh_normalize_url_path /example/ # -> /example
# ynh_normalize_url_path / # -> / # ynh_normalize_url_path / # -> /
# #
# usage: ynh_normalize_url_path --path_url=path_to_normalize # usage: ynh_normalize_url_path path_to_normalize
# | arg: -p, --path_url= - URL path to normalize before using it
# #
# Requires YunoHost version 2.6.4 or higher. # Requires YunoHost version 2.6.4 or higher.
ynh_normalize_url_path() { ynh_normalize_url_path() {
# ============ Argument parsing ============= local path_url=$1
local -A args_array=([p]=path_url=)
local path_url
ynh_handle_getopts_args "$@"
# ===========================================
test -n "$path_url" || ynh_die --message="ynh_normalize_url_path expect a URL path as first argument and received nothing." test -n "$path_url" || ynh_die --message="ynh_normalize_url_path expect a URL path as first argument and received nothing."
if [ "${path_url:0:1}" != "/" ]; then # If the first character is not a / if [ "${path_url:0:1}" != "/" ]; then # If the first character is not a /