Skip to content

forge: extract shared URL parsing utilities#1013

Merged
abhinav merged 1 commit intoabhinav:mainfrom
irl-llc:gs/forge-url-refactor
Feb 7, 2026
Merged

forge: extract shared URL parsing utilities#1013
abhinav merged 1 commit intoabhinav:mainfrom
irl-llc:gs/forge-url-refactor

Conversation

@ed-irl
Copy link
Contributor

@ed-irl ed-irl commented Feb 6, 2026

Extract duplicate URL parsing code from github and gitlab forges into a new internal/forge/urls package.

The new package provides:

  • HasGitProtocol: check if URL has a known git protocol
  • Parse: parse git remote URLs, normalizing SCP-style SSH syntax
  • StripDefaultPort: remove default ports when base URL doesn't specify one
  • MatchesHost: check if hosts match including subdomains
  • ExtractPath: extract owner/repo from URL path

This reduces code duplication and will allow the bitbucket forge to reuse the same URL parsing logic.

@ed-irl
Copy link
Contributor Author

ed-irl commented Feb 6, 2026

@abhinav since this is not user facing, if you could add the skip changelog label that would be helpful 🙏

@abhinav abhinav added the skip changelog PRs that don't need a changelog. label Feb 6, 2026
@abhinav
Copy link
Owner

abhinav commented Feb 6, 2026

Done!

FYI you can also add [skip changelog]: cause to the PR message to skip the check.

I'll review and merge tonight or this weekend, but one early piece of feedback:
I try to avoid pluralized package names (except for reserved type names). Since "url" is already taken, how do you feel about "forgeurl" as the package name?

@ed-irl ed-irl force-pushed the gs/forge-url-refactor branch from 245b5fd to 24529d0 Compare February 6, 2026 14:25
Extract duplicate URL parsing code from github and gitlab forges
into a new internal/forge/urls package.

The new package provides:
- HasGitProtocol: check if URL has a known git protocol
- Parse: parse git remote URLs, normalizing SCP-style SSH syntax
- StripDefaultPort: remove default ports when base URL doesn't specify one
- MatchesHost: check if hosts match including subdomains
- ExtractPath: extract owner/repo from URL path

This reduces code duplication and will allow the bitbucket forge
to reuse the same URL parsing logic.
@ed-irl ed-irl force-pushed the gs/forge-url-refactor branch from 24529d0 to f6e1cf1 Compare February 6, 2026 14:28
Copy link
Owner

@abhinav abhinav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines +350 to +358

Do not pluralize package names.
Use singular nouns or compound names instead.

```
// BAD: pluralized package names
urls
utils
helpers
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

thanks!

@abhinav abhinav merged commit 1aec63c into abhinav:main Feb 7, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changelog PRs that don't need a changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants