[Slogger] Trouble With Variable "$url"

Ken Schutte kschutte at mit.edu
Thu Feb 16 21:36:59 EST 2006


mook at themook.net wrote:
> 
> Also, when I go back to the "Custom Script" tab, my code has 
> been changed!  It no longer contains the escaping slashes, for 
> example:
> 
> a = a.replace(new RegExp(/\//gi), "_");
> 
> ... is now ...
> 
> a = a.replace(new RegExp(///gi), "_");
> 

Ahh, yeah you picked up on a couple mistakes,  the "a.replace()" returns 
the new string, instead of modifying "a".  The other problem is with 
escaping special characters, and is pretty confusing.  Put this as the 
script:

var a = sloggerGetVar("url");
a = a.replace(/\\\:/g, "_");
a = a.replace(/\\\?/g, "_");
a = a.replace(/\\\//g, "_");
sloggerSetVar("url",a);

This should work, ... BUT if you ever modify that profile again (i.e. 
Edit Profile and hit OK), it you'll notice the extra pair "\\" missing 
in each line, and you'd have to add them back again.  Yeah, this is a 
delicate hack, but should work for now...

Ken


More information about the Slogger mailing list