构建 Reducisaurus URL

发布于 2024-08-31 13:18:57 字数 1678 浏览 4 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

坐在坟头思考人生 2024-09-07 13:18:57

是的,在将 URL 作为参数提交给另一个 Web 服务之前,您需要对 URL 进行 URL 编码。

例如,

http://google.com

如果

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

您这样做,则不会有像 ?、&、= 等特殊字符在可能会混淆 Web 服务的过程中幸存下来。

(不太确定你的第二个问题要问什么,抱歉。)

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.)

喜你已久 2024-09-07 13:18:57

以 url 开头的所有内容都将被视为新的 url,因此您不能将名为 url2 的参数作为 url1 的 get 参数传递。

每个不包含“-”的参数名称将被视为输入。

因此,如果您这样做,

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

最大年龄将不会被视为输入。

然而,

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

这里 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

...?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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文