views:

52

answers:

2

I'm trying to use Reducisaurus Web Service to minify CSS and Javascript but I've run into a problem...

Suppose I've two unminified CSS at:

http:/domain.com/dynamic/styles/theme.php?color=red
http:/domain.com/dynamic/styles/typography.php?font=Arial

According to the docs I should call the web service like this:

http:/reducisaurus.appspot.com/css?url=http:/domain.com/dynamic/styles/theme.php?color=red

And if I want to minify both CSS files at once:

http:/reducisaurus.appspot.com/css?url1=http:/domain.com/dynamic/styles/theme.php?color=red&url2=http:/domain.com/dynamic/styles/theme.php?color=red

If I wanted to specify a different number of seconds for the cache (3600 for instance) I would use:

http:/reducisaurus.appspot.com/css?url=http:/domain.com/dynamic/styles/theme.php?color=red&expire_urls=3600

And again for both CSS files at once:

http:/reducisaurus.appspot.com/css?url1=http:/domain.com/dynamic/styles/theme.php?color=red&url2=http:/domain.com/dynamic/styles/theme.php?color=red&expire_urls=3600

Now my question is, how does Reducisaurus knows how to separate the URLs I want? How does it know that &expire_urls=3600 is not part of my URL? And how does it know that &url2=... is not a GET argument of url1? I'm I doing this right? Do I need to urlencode my URLs?

I took a peek into the source code and although my Java is very poor it seems that the methods acquireFromRemoteUrl() and getSortedParameterNames() from the BaseServlet.java file hold the answers to my question - if a GET argument name contains - or _ they should be ignored?!

What about multiple &url(n)s?

+1  A: 

Yes, you need to URL encode your URLs before you submit them as a parameter to another webservice.

E.g.

http://google.com

Becomes

http%3A%2F%2Fgoogle.com

If you do that, no special characters like ?, &, = et cetera survive the process that could confuse the webservice.

(Not quite sure what you're asking with your second question, sorry.)

pinkgothic
+1  A: 

everything which starts with url is threated as a new url, so you cannot pass a parameter called url2 as a get argument of url1.

Every param name that does not contain a '-' will be treated as input.

So if you do

...?file1=...&url1=...&max-age=604800,

the max-age will not be treated as input.

However,

...?file1=...&url1=...&maxage=604800

here the maxage will be treated as input.

Fortega
Thanks, that's what I though. Regarding urlencoding, is it necessary?
Alix Axel