mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
var url = Npm.require("url");
|
|
|
|
Tinytest.add("spiderable - phantom url generation", function (test, expect) {
|
|
var absUrl = "http://example.com";
|
|
_.each([
|
|
{
|
|
requestUrl: "/?_escaped_fragment_=1",
|
|
expected: "/"
|
|
},
|
|
// Test that query strings are preserved
|
|
{
|
|
requestUrl: "/?_escaped_fragment_=1&foo=bar",
|
|
expected: "/?foo=bar"
|
|
},
|
|
{
|
|
requestUrl: "/?foo=bar&_escaped_fragment_=1",
|
|
expected: "/?foo=bar"
|
|
},
|
|
// Test that paths are preserved
|
|
{
|
|
requestUrl: "/foo/bar?_escaped_fragment_=1",
|
|
expected: "/foo/bar"
|
|
},
|
|
{
|
|
requestUrl: "/foo/bar?_escaped_fragment_=1&foo=bar",
|
|
expected: "/foo/bar?foo=bar"
|
|
},
|
|
// Test with a path on the site's absolute url
|
|
{
|
|
requestUrl: "/foo/bar?_escaped_fragment_=1",
|
|
expected: "/foo/bar",
|
|
absUrl: "http://example.com/foo"
|
|
},
|
|
{
|
|
requestUrl: "/bar?_escaped_fragment_=1",
|
|
expected: "/bar",
|
|
absUrl: "http://example.com/foo"
|
|
}
|
|
], function (testCase) {
|
|
testCase.absUrl = testCase.absUrl || absUrl;
|
|
|
|
test.equal(
|
|
Spiderable._urlForPhantom(absUrl, testCase.requestUrl),
|
|
absUrl + testCase.expected
|
|
);
|
|
});
|
|
});
|