构建 Reducisaurus URL
我正在尝试使用 Reducisaurus Web Service 来缩小 CSS 和 Javascript,但我已经运行遇到问题...
假设我有两个未缩小的CSS:
http:/domain.com/dynamic/styles/theme.php?color=red
http:/domain.com/dynamic/styles/typography.php?font=Arial
根据文档,我应该像这样调用Web服务:
http:/reducisaurus.appspot.com/css?url=http:/domain.com/dynamic/styles/theme.php?color=red
如果我想一次缩小两个CSS文件:
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
如果我想指定不同的秒数对于缓存(例如 3600),我会使用:
http:/reducisaurus.appspot.com/css?url=http:/domain.com/dynamic/styles/theme.php?color=red&expire_urls=3600
再次对于两个 CSS 文件:
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
现在我的问题是,Reducisaurus 如何知道如何分隔我想要的 URL?它如何知道&expire_urls=3600
不是我的网址的一部分?它如何知道 &url2=...
不是 url1
的 GET 参数?我这样做对吗?我需要对我的网址进行urlencode
吗?
我看了一下源代码,虽然我的Java很差,但似乎 BaseServlet.java 文件中的 acquireFromRemoteUrl()
和 getSortedParameterNames()
方法保存了我的答案问题 - 如果 GET 参数名称包含 -
或 _
它们应该被忽略?!
多个 &url(n)
怎么样?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,在将 URL 作为参数提交给另一个 Web 服务之前,您需要对 URL 进行 URL 编码。
例如,
如果
您这样做,则不会有像 ?、&、= 等特殊字符在可能会混淆 Web 服务的过程中幸存下来。
(不太确定你的第二个问题要问什么,抱歉。)
Yes, you need to URL encode your URLs before you submit them as a parameter to another webservice.
E.g.
Becomes
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.)
以 url 开头的所有内容都将被视为新的 url,因此您不能将名为 url2 的参数作为 url1 的 get 参数传递。
每个不包含“-”的参数名称将被视为输入。
因此,如果您这样做,
最大年龄将不会被视为输入。
然而,
这里 maxage 将被视为输入。
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
the max-age will not be treated as input.
However,
here the maxage will be treated as input.