UrlBuilder

Presenting UrlBuilder, it doesn't do much but seeing a string get broken down into parts apparently gave me satisfaction

Since I officially called it a 'series' in my first post, I'm going to keep documenting the experience of re-discovering nonsense that I wrote so long ago I don't remember the purpose of.
This next part is an unfortunately common find - UrlBuilder is a half-baked attempt to create a reusable class to manage urls in PowerShell.

Now I know the rest of the world is just doing string concatenation to build urls in PowerShell, but it looks like at one point I thought I could make it better, or I probably just thought I was being clever.

$baseUrl = "https://api.example.com/v1"
$userQuery = $baseUrl + "?user=john.smith&format=json"

A normal way to do this

Just like my last post, I don't know why I made this, but here you go

So this was clearly inspired by me seeing a UrlBuilder class in another language and thinking I could implement something in PowerShell that made working with endpoints more object-oriented.

Why they'd need to be more object oriented (and also now require dependency files) is no longer clear to me.

It's basically a way to turn a url into an object, and manipulate it using functions instead of adding/removing the raw text.

I will say this, seeing a url get deconstructed into parts and spat out as an object, it does scratch an itch in my brain, maybe that's why I made this?
Itch scratched or not, I never used this again.

Subscribe for more of this