You are here

function fb_scrub_urls in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 5.2 fb.module \fb_scrub_urls()
  2. 5 fb.module \fb_scrub_urls()
  3. 6.3 fb.module \fb_scrub_urls()
  4. 6.2 fb.module \fb_scrub_urls()

This method will clean up URLs. When serving canvas pages, extra information is included in URLs. This will remove the extra information. Useful when linking back to the website from a canvas page or wall post.

For example in the following code, $url2 will link out to the server's domain:

$url = url('node/42', array('absolute' => TRUE)); // i.e. http://apps.facebook.com/example/node/42 $url2 = fb_scrub_urls($url); // i.e. http://example.com/node/42

See also

fb_url_rewrite.inc

2 calls to fb_scrub_urls()
fb_example_node_view in contrib/fb_example.module
Implements hook_node_view().
fb_init in ./fb.module
Implements hook_init().

File

./fb.module, line 1674
This is the core required module of Drupal for Facebook.

Code

function fb_scrub_urls($content) {
  if (function_exists('_fb_settings_url_rewrite_prefixes')) {
    foreach (_fb_settings_url_rewrite_prefixes() as $key) {
      $patterns[] = "|{$key}/[^/]*/|";
      $replacements[] = "";
    }
    $content = preg_replace($patterns, $replacements, $content);
  }
  return $content;
}