How to generate URL alias without %20 in URL? We have a custom field that is being used to generate the URL alias.

One issue we have found is that when we set the page to "Autogenerate URL Alias" and set the URL pattern to "[node:field_custom_url]", we are still getting "%20" where the space should be. 

We have done the following, but nothing seems to work. We needed assistance to see what else needs to be configured. Ideally, any spaces should be replaced with a "-" instead of "%20". Any thoughts?

Current settings (found in admin/config/search/path/settings):


Path pattern = "[node:field-custom-url]" (we even tried [node:field_custom_url], but it did not work)
Create a new alias. Delete the old alias. = Enabled
Separator = "-"
Transliterate prior to creating alias = Enabled
Reduce strings to letters and numbers
It is proved that I wrote wrongly in the beginning, thanks @Beebee.


  I have read through the code of pathauto module. The module
  implements the token replacement after replacing the space with
  defined separator. So there is no clue by configuration. I would
  consider it is a design fault of the module.


pathauto module clean the url only when the token name does not match with the pattern /(path|alias|url|url-brief)\]$/. You can find it in the function pathauto_clean_token_values(). Obviously, the module author would like to prevent the url alias to be clean twice. As your field name is custom_url, so it is escaped from the checking.

You can fix this by changing your field name or writing your own module as I stated before.



If you know how to create custom module. I would recommend you to implement hook_pathauto_alias_alter for the purpose.

/**
 * Implements hook_pathauto_alias_alter().
 */
function mymodule_pathauto_alias_alter(&amp;$alias, array &amp;$context) {
  $separator = variable_get('pathauto_separator', '-');
  $alias = preg_replace('/\s+/', $separator, $alias);
}