Everywhere where we request the user to enter a URL alias, we have help text like this one (node add form):
The alternative URL for this content. Use a relative path without a trailing slash.
...or this one (add taxonomy term form):
Optionally specify an alternative URL by which this term can be accessed. Use a relative path and don't add a trailing slash or the URL alias won't work.
...or this one ():
Optional subdirectory within the upload destination where files will be stored. Do not include preceding or trailing slashes.
Well if we know that we allow values that will make things not work, then why not run a validation and remove preceding and/or trailing slashes instead of asking the user to remember not to do this.
Also, for the relative path thing, why not add the domain part as a prefix before the field (like we do for the front page and the 403/404 error URLs in /admin/config/system/site-information
)?
That should give people a better hint.
I think that we could validate those fields like so:
1. search for any occurrence of ://
and remove that and any text before it.
2. search for any occurrence of a string that matches the domain name in the beginning of the typed/entered URL. If the site URL is my.site.net and people enter something like my.site.net/myalias
, then remove the my.site.net/
part.
3. if the first character of the field value is /
, remove it.
4. if the last character of the field value is /
, remove it.
Recent comments
Hello. I'm stuck at the Drupal > Backdrop update step at /core/updatte.php with an error: The configuration directory in settings.php is specified as './files/config/active', but this...
Configuration directory "empty or missing crucial files" after site copy
Tried and successfully applied DrAlbany's method with the form https://www.drupal.org/sandbox/grobot/2105379stickman hook. I also encountered the same situation. Thanks DrAlbany
Ubercart - Auto increment SKU
Since before migration you need to prepare the Drupal site - disabling and removing all modules, disabling themes, as part of the preparation you can clear the cache and logs, delete the search...
Trimming the size of my database for D2B_migrate not to error out (Request Entity Too Large / 504 Gateway Time-out)