1 | var trim = require('../utils/trim');
|
2 |
|
3 | function parse(content) {
|
4 | content = trim(content);
|
5 |
|
6 | // Search: type, url and title
|
7 | // Example: {get} /user/:id Get User by ID.
|
8 | var parseRegExp = /^(?:(?:\{(.+?)\})?\s*)?(.+?)(?:\s+(.+?))?$/g;
|
9 | var matches = parseRegExp.exec(content);
|
10 |
|
11 | if ( ! matches)
|
12 | return null;
|
13 |
|
14 | return {
|
15 | type : matches[1],
|
16 | url : matches[2],
|
17 | title: matches[3] || ''
|
18 | };
|
19 | }
|
20 |
|
21 | /**
|
22 | * Exports
|
23 | */
|
24 | module.exports = {
|
25 | parse : parse,
|
26 | path : 'local',
|
27 | method: 'insert'
|
28 | };
|