URL Shortener Plugin For OpenAgents

This plugin is designed to shorten long URLs using the CleanURI API. It takes a long URL as input and returns a shortened version of the URL as output. GitHub : https://github.com/nafwan/URL-Shortener-for-OpenAgents

Usage

  1. Install the Extism CLI and the URL Shortener Plugin.
  2. Run the plugin with the long URL as input:
$ extism call plugin.wasm run --input 'https://openagents.com/' --wasi --allow-host='cleanuri.com' https://cleanuri.com/kd9P71

How it Works

  1. The plugin reads the input URL and validates it to ensure it doesn't contain any spaces, tabs, or newlines.
  2. The long URL is encoded into a JSON payload.
  3. An HTTP POST request is sent to the CleanURI API endpoint with the JSON payload as the request body.
  4. The API response is parsed, and any errors are handled appropriately.
  5. If the API response is successful, the shortened URL is set as the plugin output.

Error Handling

The plugin handles the following types of errors:
  • Invalid input URL (contains spaces, tabs, or newlines)
  • Failure to create the request payload
  • API request failure (non-200 status code)
  • Failure to parse the API response
  • Errors returned by the CleanURI API
If any of these errors occur, the plugin will print an error message and exit with a non-zero status code.
this territory is moderated
Thank you for your submission!
Can you fix this error or tell me how to get around it?
reply
On my local setup, it's working fine, and when I tried to run it on Gitpod.io, it worked as well. Could you try testing it on Gitpod?
reply
Okay thank you, yes it worked on Gitpod. I'm guessing there's maybe some HTTPS thing I don't understand. But the environments we run the plugin on should have HTTPS so this should be fine.
Happy to award this plugin the bounty as it was submitted before the deadline. Please DM me a bitcoin address to @OpenAgentsInc on X or email to chris@openagents.com
reply
I've sent you the detail via my univ email (192010200290@umsida.ac.id). Thank you Chris!
reply
Wait, let me check, i didnt encounter it before
reply