0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Merge pull request #1729 from mjbshaw/escape-regex

Escape URL for use in regex
This commit is contained in:
Hannah Wolfe 2013-12-21 15:15:55 -08:00
commit f0b0291007

View file

@ -1,5 +1,7 @@
/*globals casper, __utils__, url, testPost */
var escapedUrl = url.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
CasperTest.begin("Ghost editor is correct", 10, function suite(test) {
casper.thenOpen(url + "ghost/editor/", function testTitleAndUrl() {
test.assertTitle("Ghost Admin", "Ghost admin has no title");
@ -32,7 +34,7 @@ CasperTest.begin("Ghost editor is correct", 10, function suite(test) {
casper.thenClick('.js-publish-button');
casper.waitForResource(/posts/, function checkPostWasCreated() {
var urlRegExp = new RegExp("^" + url + "ghost\/editor\/[0-9]*");
var urlRegExp = new RegExp("^" + escapedUrl + "ghost\/editor\/[0-9]*");
test.assertUrlMatch(urlRegExp, 'got an id on our URL');
test.assertExists('.notification-success', 'got success notification');
test.assertEvalEquals(function () {
@ -163,7 +165,7 @@ CasperTest.begin('Publish menu - existing post', 22, function suite(test) {
casper.thenClick('.js-publish-button');
casper.waitForResource(/posts/, function checkPostWasCreated() {
var urlRegExp = new RegExp("^" + url + "ghost\/editor\/[0-9]*");
var urlRegExp = new RegExp("^" + escapedUrl + "ghost\/editor\/[0-9]*");
test.assertUrlMatch(urlRegExp, 'got an id on our URL');
});
@ -200,7 +202,7 @@ CasperTest.begin('Publish menu - existing post', 22, function suite(test) {
casper.thenClick('.js-publish-button');
casper.waitForResource(/posts/, function checkPostWasCreated() {
var urlRegExp = new RegExp("^" + url + "ghost\/editor\/[0-9]*");
var urlRegExp = new RegExp("^" + escapedUrl + "ghost\/editor\/[0-9]*");
test.assertUrlMatch(urlRegExp, 'got an id on our URL');
});
@ -236,4 +238,4 @@ CasperTest.begin('Publish menu - existing post', 22, function suite(test) {
}, function onTimeout() {
test.assert(false, 'Publish split button should have .splitbutton-delete');
});
});
});