URLs should allow anchors

Created on 21 April 2023, over 1 year ago
Updated 8 September 2023, about 1 year ago

All URL input fields on /admin/config/system/cookies/texts should allow anchor URLs. To enable we should change the validate function within /src/Form/CookiesTextsForm.php

    // Validate front page path.
    if (($value = $form_state->getValue('imprintUri')) && !preg_match('/^http(s)?:\/\//', $value) && $value[0] !== '/') {

should be

    // Validate front page path.
    if (($value = $form_state->getValue('imprintUri')) && !preg_match('/^http(s)?:\/\//', $value) && $value[0] !== '/'  && $value[0] !== '#') {

AND

    // Validate privacy uri.
    if (($value = $form_state->getValue('privacyUri')) && !preg_match('/^http(s)?:\/\//', $value) && $value[0] !== '/') {

should be

    // Validate privacy uri.
    if (($value = $form_state->getValue('privacyUri')) && !preg_match('/^http(s)?:\/\//', $value) && $value[0] !== '/' && $value[0] !== '#') {

AND

    // Validate front page path.
    if (($value = $form_state->getValue('cookieDocsUri')) && !preg_match('/^http(s)?:\/\//', $value) && $value[0] !== '/') {

should be

    // Validate front page path.
    if (($value = $form_state->getValue('cookieDocsUri')) && !preg_match('/^http(s)?:\/\//', $value) && $value[0] !== '/' && $value[0] !== '#') {

The error message has to be extended from
The path '%path' has to start with a slash.
To
The path '%path' has to start with a slash or a #.

โœจ Feature request
Status

Needs work

Version

1.2

Component

Code

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany vistree

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024