You are here

function pathauto_clean_alias in Pathauto 6

Same name and namespace in other branches
  1. 6.2 pathauto.inc \pathauto_clean_alias()
  2. 7 pathauto.inc \pathauto_clean_alias()

Clean up an URL alias.

Performs the following alterations:

  • Trim duplicate, leading, and trailing back-slashes.
  • Trim duplicate, leading, and trailing separators.
  • Shorten to a desired length and logical position based on word boundaries.

Parameters

$alias: A string with the URL alias to clean up.

Return value

The cleaned URL alias.

1 call to pathauto_clean_alias()
pathauto_create_alias in ./pathauto.inc
Apply patterns to create an alias.

File

./pathauto.inc, line 234
Miscellaneous functions for Pathauto.

Code

function pathauto_clean_alias($alias) {
  $output = $alias;

  // Trim duplicate, leading, and trailing back-slashes.
  $output = _pathauto_clean_separators($output, '/');

  // Trim duplicate, leading, and trailing separators.
  $output = _pathauto_clean_separators($output);

  // Enforce the maximum length.
  $separator = variable_get('pathauto_separator', '-');
  $maxlength = min(variable_get('pathauto_max_length', 100), _pathauto_get_schema_alias_maxlength());
  $output = drupal_substr($output, 0, $maxlength);
  return $output;
}