The stubbed-out function in js_theming.js that is named Drupal.urlEncode() appears to be a duplicate of a function already provided in drupal.js.

Drupal.encodeURIComponent() appears to provide the same functionality (correctly handing slashes and some entities) that Drupal.urlEncode() provides. Apparently, the drupal.js developers decided to name the function after its nearest JS neighbor (encodeURIComponent()) rather than its nearest Drupal PHP neighbor. ('course the scant documentation on Drupal.encodeURIComponent certainly doesn't help clear this up).

So if I'm correctly interpreting the comments in js_theming.js, then I suppose there are a few possible courses of action:

* Perhaps wrapping Drupal.encodeURIComponent() would be a useful thing to do. After all, Drupal.urlEncode() is a lot easier to intuit than Drupal.encodeURIComponent().

* Or, Drupal.urlEncode() could simply be removed.

BTW -- there is a minor formatting error in the function declaration for Drupal.strEqual (at least in the dev release -- haven't checked CVS at all). There is a space between the Drupal. and the strEqual. Seems silly to file a bug just about that, though.

CommentFileSizeAuthor
#3 patch_311865_02.txt3.92 KBmbutcher
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

litwol’s picture

I created urlEncode out of lack of knowledge that encodeURIComponent existed.

I am very open to help in collaborating to fix this and provide new features. Would you be willing to provide a patch since you've noticed this and seem to have better understanding of the issue than myself. I wrote this module over a weekend to strart something 'cool' and i lacked proper JS knowledge to do it right from the beginning. please help :). Thank you very much.

mbutcher’s picture

The module is indeed very cool, and I am happy to have found it.

I would be happy to contribute a patch for the issue.

mbutcher’s picture

Status: Active » Needs review
FileSize
3.92 KB

Attached is a patch that addresses several issues with various aspects of the URL encoding features. Among the fixes in the patch:

  • Drupal.queryStringEncode() now correctly handles arrays, correctly handles encoding, correctly constructs query string
  • Drupal.strEqual() is removed; it is not a generalized function.
  • Drupal.urlEncode() now does URL encoding using Drupal.encodeURIComponent()
  • Minor formatting fixes
  • Minor doc block fixes

See also #316749: Messaging Bugs for a patch to messaging that relates to this patch (by removing dependency on Drupal.strEqual()).

litwol’s picture

Status: Needs review » Fixed

Commited: http://drupal.org/cvs?commit=147974

Thank you. I hope more patches from you will follow :-D. new functionality etc :-D

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.