You are here

function fb_scrub_urls in Drupal for Facebook 6.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.2 fb.module \fb_scrub_urls()
  4. 7.3 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

7 calls to fb_scrub_urls()
fb_devel_tab in ./fb_devel.module
Provides a profile tab (FBML) with useful debug info.
fb_example_link in contrib/fb_example.module
Implements hook_link().
fb_example_nodeapi in contrib/fb_example.module
Implements hook_nodeapi().
fb_friend_block in contrib/fb_friend.module
Implementation of hook_block().
fb_init in ./fb.module
Implements hook_init().

... See full list

File

./fb.module, line 1388
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;
}