verbb / hyper

A Craft CMS plugin for managing links, focusing on user experience.
Other
24 stars 15 forks source link

Anchor Links arent migrated from Typed Link Field #175

Closed DanielDarrenJones closed 4 months ago

DanielDarrenJones commented 4 months ago

Describe the bug

When migrating from the Typed Link Field plugin anchor links are still are still kept as a URL rather than custom even though they require validation to be disabled.

We could add a regex check for these like so: https://regex101.com/r/ZMtQk3/1 and if the URL is an anchor like so #example-id then we could set this to be a type of custom?

Although is there a reason these aren't considered a valid URL?

Steps to reproduce

  1. Install Typed Link Field
  2. Create a field with URL's enabled and validation disabled
  3. Add an anchor link like #example-id
  4. run the migration to Hyper
  5. The links stay as the URL type and wont let you save the page as they fail the URL validation check.

Craft CMS version

5.2.3

Plugin version

2.0.2

Multi-site?

Yes

Additional context

No response

engram-design commented 4 months ago

Right, so that's a little more complicated with Hyper, as a Hyper link does need to be a URL, not just an anchor. I know Typed Link has a way around this with disabling validation, but I've never really liked that approach.

So our options are either to just add support for anchor links in the link field itself, or some other much more involved solution that involves using the URL Suffix field for a link, and having the Link Value empty. The latter is more complicated in a few ways as it requires you to have that field enabled for the link type.

But anchor links do kind of sit under the "Custom" link type personally. After all, #example-id might be considered a link, but it's not a URL.

So really, this is something that should be "fixed" in Typed Link before things are migrated (changing links to be Custom not URL - because they aren't URLs), but happy to make changes on our end to ease the migration. Now, during the migration we'll switch the URL link type to a Custom link type, if it's detected as an anchor link.

To get this early, run composer require verbb/hyper:"dev-craft-4 as 1.1.32".

engram-design commented 4 months ago

Updated in 1.2.0