#```console

1 messages ยท Page 1 of 1 (latest)

prime copper
#

what's the output when you run git remote -v in that directory?

frail adder
#

guessing
ssh://git@github.com/shykes/daggerverse ๐Ÿช™

lost yarrow
#
% git remote -v
origin   ssh://git@github.com/shykes/daggerverse (fetch)
origin  ssh://git@github.com/shykes/daggerverse (push)
frail adder
lost yarrow
#

Note, I didn't touch my remotes recently. First time I get this error on dagger mod publish (usually it just happily returns, and does nothing)

prime copper
#

Yeah I'm trying to decide if it's worth just expanding the regex further or find some better way

#

"Write a regex that accounts for every possible git url format" sounds like a form of torture

frail adder
#

on it

prime copper
#

there hasto be a library somewhere for this, just need to find it

frail adder
#

To create a regex pattern for the secure Git URL formats from the given sections, we would need to capture:

  1. Local Filesystem Paths: Both absolute and relative paths.
  2. HTTP(S): Only https:// since it's the secure version.
  3. SSH: Both full and shorthand versions.

Here's a regex pattern that should capture those:

^(\/[^\s]+|https:\/\/[a-zA-Z0-9.-]+(\/[^\s]*)?|ssh:\/\/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+(:[0-9]+)?(\/[^\s]*)?|[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+:(\/?[^\s]+)?)$

This regex assumes:

  • A local path starting with /.
  • URLs with valid characters (like alphanumeric characters, dots, hyphens).
  • SSH usernames and hostnames with valid characters.

Breakdown:

  1. ^(\/[^\s]+: Matches absolute paths.
  2. https:\/\/[a-zA-Z0-9.-]+(\/[^\s]*)?: Matches https:// URLs.
  3. ssh:\/\/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+(:[0-9]+)?(\/[^\s]*)?: Matches full SSH URLs.
  4. [a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+:(\/?[^\s]+)?: Matches shorthand SSH URLs.

However, this regex does have some limitations:

  • It doesn't fully validate domain names or URLs.
  • It assumes that a valid SSH username or hostname doesn't have special characters except . _ % -.

Always remember, while regex can help validate structure, it doesn't guarantee the functionality or authenticity of a URL. Always validate and sanitize user input in applications and use safe methods to clone or interact with Git URLs.

prime copper
#

The chatgpt one was close but slightly off and I didn't want to try editing that regex ๐Ÿ™‚