From 3cd3e45d7c58c2215385f90b8f59025632f523d8 Mon Sep 17 00:00:00 2001 From: Teepob Harutaipree Date: Tue, 12 Mar 2024 21:01:55 +0700 Subject: [PATCH] simplify title encoding logic and change the params to pass correctly --- commands/developer-utils/create-image-from-code.sh | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/commands/developer-utils/create-image-from-code.sh b/commands/developer-utils/create-image-from-code.sh index 8b7e9387a..2a3aa7792 100755 --- a/commands/developer-utils/create-image-from-code.sh +++ b/commands/developer-utils/create-image-from-code.sh @@ -7,7 +7,7 @@ # Optional parameters: # @raycast.icon ./images/ray-so.png -# @raycast.argument1 { "type": "text", "placeholder": "Title", "optional": true } +# @raycast.argument1 { "type": "text", "placeholder": "Title", "optional": true, "percentEncoded": true } # Documentation: # @raycast.description Create beautiful images of your code with https://ray.so @@ -29,16 +29,10 @@ PADDING="64" LANGUAGE="auto" # Main: - -if [[ -z "$1" ]] -then - TITLE="Untitled-1" -else - TITLE=$(php -r "echo urlencode(\"$1\");") -fi +TITLE=${1:-"Untitled"} CODE=$(pbpaste | base64) # Urlencode any + symbols in the base64 encoded string CODE=${CODE//+/%2B} -open "https://ray.so/?colors=$COLORS&background=$BACKGROUND&darkMode=$DARK_MODE&padding=$PADDING&title=$TITLE&code=$CODE&language=$LANGUAGE" +open "https://ray.so?#title=$TITLE&code=$CODE&colors=$COLORS&background=$BACKGROUND&darkMode=$DARK_MODE&padding=$PADDING&title=$TITLE&code=$CODE&language=$LANGUAGE"