tidy-url icon indicating copy to clipboard operation
tidy-url copied to clipboard

Request: Move handlers into their own functions

Open DrKain opened this issue 1 year ago • 8 comments

Right now almost all of the work is done in a single function, clean().
I want to split each of the parts into their own functions for easier managing and more control over the process.

Currently this is what happens in the clean function (not in order):

  • Redirecting based on parameter
  • Rebuilding URL
  • Delete parameters
  • Updating path names
  • Handle AMP redirects
  • Fetching matching rules
  • ~~Decode handler~~
  • ~~Empty hashes~~
  • Removing empty values
  • ~~Checking reduction/difference~~

I think handlers should get their own file to make the project easier to read and/or debug.
If anyone has thoughts on this feel free to contact me privately (email on my profile) or you can leave a comment on this issue.

DrKain avatar Dec 07 '23 20:12 DrKain

I am interested in taking this on. I'm thinking (as a first pass at least) of splitting each of the aforementioned things into functions. Also, what are your thoughts on clean() taking a config object or something so that the caller can decide which parts of the cleaning process they want to run? I'm thinking object to allow for more flexibility & ease in adding/removing options down the line.

jugaltheshah avatar Jan 04 '24 00:01 jugaltheshah

That sounds good to me as long as the config object is optional. My original goal was simplicity, being able to pass any URL to be cleaned with ease, but I don't mind being able to customize the clean for more advanced users. So far the main options were for AMP links and redirects, as you've probably seen already

DrKain avatar Jan 04 '24 00:01 DrKain

I am interested. I will refactor the code and add some unit tests to make the method cleaner and more readable. Additionally, I will organize the handlers into different files.

apodi avatar Apr 08 '24 12:04 apodi

Thank you

DrKain avatar Apr 08 '24 14:04 DrKain

I think i do not have permission to push git push --set-upstream origin refactor/handlers remote: Permission to DrKain/tidy-url.git denied to apodi. fatal: unable to access 'https://github.com/DrKain/tidy-url.git/': The requested URL returned error: 403 could you please add me as Collaborator

apodi avatar Apr 08 '24 18:04 apodi

Create a pull request. I'll review it when I get the time and if it's good I'll merge

DrKain avatar Apr 08 '24 18:04 DrKain

I'm not going to let you push code into the main branch that hasn't been tested, reviewed or even seen by me.

DrKain avatar Apr 08 '24 18:04 DrKain

PR is ready for review https://github.com/DrKain/tidy-url/pull/108

apodi avatar Apr 08 '24 18:04 apodi