can3p (can3p) wrote in changelog,
can3p
can3p
changelog

[livejournal] r22436: LJSUP-12895: AJAX pagination for new com...

Committer: dpetrov
LJSUP-12895: AJAX pagination for new comments pages. Fix LiveJournal.constructUrl to always return a valid url.
U   trunk/htdocs/js/livejournal.js
Modified: trunk/htdocs/js/livejournal.js
===================================================================
--- trunk/htdocs/js/livejournal.js	2012-07-13 07:21:57 UTC (rev 22435)
+++ trunk/htdocs/js/livejournal.js	2012-07-13 08:10:50 UTC (rev 22436)
@@ -349,10 +349,16 @@
  * @return {String}
  */
 LiveJournal.constructUrl = function(base, args, escapeArgs) {
-	var queryStr = base + ( base.indexOf('?') === -1 ? '?' : '&' ), queryArr = [];
+	base = base.replace(/(\&|\?)+$/g, '');
+	var queryStr = base,
+		queryArr = [];
+	
+	if (args) {
+		queryStr += ( base.indexOf('?') === -1 ? '?' : '&' );
 
-	for (var i in args) {
-		queryArr.push(i + '=' + ( ( escapeArgs ) ? encodeURIComponent(args[i]) : args[i] ));
+		for (var i in args) {
+			queryArr.push(i + '=' + ( ( escapeArgs ) ? encodeURIComponent(args[i]) : args[i] ));
+		}
 	}
 
 	return queryStr + queryArr.join('&');

Tags: can3p, dpetrov, js, livejournal
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments