hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Using just a hash returns 'Link is not a valid URL.'

Open mattbloomfield opened this issue 1 year ago • 1 comments

Describe the bug

Sometimes we just want to add a jump link on the page. I would expect to be able to add #jump-to-here as the input text on link field

Steps to reproduce

  1. Create a hyper field
  2. Add the following as a URL: `#my-custom-id
  3. Try to save the page

Craft CMS version

4.10.2

Plugin version

1.1.32

Multi-site?

No

Additional context

No response

mattbloomfield avatar Aug 26 '24 22:08 mattbloomfield

It's correct behaviour that # is not a valid URL. We define a valid URL by it being an absolute URL. It's the reason why things like mailto: links won't work as a URL, because they're technically not.

For this reason, you'd pick a "Custom" link type that has no validation, and is essentially a general purpose link for you to have whatever you like in it.

engram-design avatar Aug 27 '24 02:08 engram-design

My 2 cents: if the URL /some-path is considered valid, then #some-hash should be valid too.

low avatar Dec 01 '25 19:12 low

@low Pretty sure it's just because we use the Yii UrlHelper which we just need to tweak further.

engram-design avatar Dec 03 '25 08:12 engram-design