Skip to content

Commit

Permalink
Shorten URL: percent encode URL before sending to service
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorgalvao committed Dec 4, 2024
1 parent e72e5ea commit 36134c8
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"inputType" : 2,
"outputDescription" : "URL",
"outputType" : 1,
"script" : "function alfred_args {\n \/usr\/bin\/osascript -l JavaScript -e 'function run(argv) { return JSON.stringify({ alfredworkflow: { arg: argv } }) }' \"${@}\"\n}\n\nurls=()\n\nfor url in \"${@}\"\ndo\n urls+=(\"$(\/usr\/bin\/curl curl --silent \"https:\/\/${service}\/create.php?format=simple&url=${url}\")\")\ndone\n\nalfred_args \"${urls[@]}\"",
"script" : "function alfred_args {\n \/usr\/bin\/osascript -l JavaScript -e 'function run(argv) { return JSON.stringify({ alfredworkflow: { arg: argv } }) }' \"${@}\"\n}\n\nfunction percent_encode {\n \/usr\/bin\/osascript -l JavaScript -e \"function run(argv) { return encodeURIComponent(argv[0].normalize()).replace(\/[!'()*]\/g, (c) => '%' + c.charCodeAt(0).toString(16).toUpperCase()) }\" \"${1}\"\n}\n\nurls=()\n\nfor url in \"${@}\"\ndo\n encoded=\"$(percent_encode \"${url}\")\"\n urls+=(\"$(\/usr\/bin\/curl curl --silent \"https:\/\/${service}\/create.php?format=simple&url=${encoded}\")\")\ndone\n\nalfred_args \"${urls[@]}\"",
"scriptType" : 5,
"state" : 0,
"taskDescription" : "Use is.gd to shorten URLs",
Expand Down

0 comments on commit 36134c8

Please sign in to comment.