--- logintoboggan.module	20 Apr 2008 17:51:58 -0000	1.129
+++ logintoboggan.module	3 May 2008 22:48:31 -0000
@@ -773,6 +773,24 @@ function logintoboggan_denied() {
 function logintoboggan_destination() {
   // Drupal has reset $_GET[q], so we need a workaround.
   if ($internal_path = substr(request_uri(), strlen(base_path()))) {
+    // If the language path prefixing is enabled remove it from the path.
+    switch (variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE)) {
+      case LANGUAGE_NEGOTIATION_PATH_DEFAULT:
+      case LANGUAGE_NEGOTIATION_PATH:
+        $args = explode('/', $internal_path);
+        $prefix = array_shift($args);
+
+        // Search prefix within enabled languages.
+        $languages = language_list('enabled');
+        foreach ($languages[1] as $language) {
+          if (!empty($language->prefix) && $language->prefix == $prefix) {
+            // Found a match, rebuild the path without the language.
+            $internal_path = implode('/', $args);
+            break;
+          }
+        }
+    }
+
     // Clean URLs enabled, just pass destination through.
     if (variable_get('clean_url', 0)) {
       $_REQUEST['destination'] = $internal_path;

