-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from yuki777/test-aura-route
Sanitize searchFileName
- Loading branch information
Showing
6 changed files
with
131 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
function testRegexTrue(testPattern, target) { | ||
const regexPattern = new RegExp(testPattern); | ||
// Test | ||
let match = target.match(regexPattern); | ||
console.assert(match !== null, `${target} は正規表現にマッチするはずが、マッチしませんでした。`); | ||
|
||
// Output | ||
if (match !== null) { | ||
console.log("- [x] " + target + " matched."); | ||
} else { | ||
console.log("- [ ] " + target + " should be matched."); | ||
} | ||
} | ||
|
||
function testRegexFalse(testPattern, target) { | ||
const regexPattern = new RegExp(testPattern); | ||
// Test | ||
let match = target.match(regexPattern); | ||
console.assert(match === null, `${target} は正規表現にマッチしないはずが、マッチしました。`); | ||
|
||
// Output | ||
if (match === null) { | ||
console.log("- [x] " + target + " not matched."); | ||
} else { | ||
console.log("- [ ] " + target + " should be not matched."); | ||
} | ||
} | ||
|
||
let testPattern = ''; | ||
|
||
// Test aura route | ||
testPattern = "(route|get|delete|head|options|patch|post|put)\\(['\"]([^'\"]*?)['\"]"; | ||
// $map->get('/category', '/category/path/accessed/by/user') => jump to src/Resource/Page/Category.php | ||
testRegexTrue(testPattern, "$map->get('/category', '/category/path/accessed/by/user')"); | ||
testRegexFalse(testPattern, "$map->foo('/category', '/category/path/accessed/by/user')"); | ||
// $map->route('/subCategory', '/sub-category/path/accessed/by/user') => jump to src/Resource/Page/SubCategory.php | ||
testRegexTrue(testPattern, "$map->route('/subCategory', '/sub-category/path/accessed/by/user')"); | ||
testRegexFalse(testPattern, "$map->foo('/subCategory', '/sub-category/path/accessed/by/user')"); | ||
// $map->post('/topics/index', '/topics/path/accessed/by/user') => jump to src/Resource/Page/Topics/Index.php | ||
testRegexTrue(testPattern, "$map->post('/topics/index', '/topics/path/accessed/by/user')"); | ||
testRegexFalse(testPattern, "$map->foo('/topics/index', '/topics/path/accessed/by/user')"); | ||
// $map->get('/foo-bar', '/category/path/accessed/by/user') => jump to src/Resource/Page/FooBar.php | ||
testRegexTrue(testPattern, "$map->get('/foo-bar', '/category/path/accessed/by/user')"); | ||
testRegexFalse(testPattern, "$map->foo('/foo-bar', '/category/path/accessed/by/user')"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters