Fix asset parsing for path-to-method, etc.

This commit is contained in:
Bryan Ashby 2018-07-15 11:49:56 -06:00
parent 47e34f9da7
commit 340c6ccf76
1 changed files with 10 additions and 6 deletions

View File

@ -29,19 +29,23 @@ const ALL_ASSETS = [
'sysStat', 'sysStat',
]; ];
const ASSET_RE = new RegExp('\\@(' + ALL_ASSETS.join('|') + ')\\:([\\w\\d\\.]*)(?:\\/([\\w\\d\\_]+))*'); const ASSET_RE = new RegExp(
'^@(' + ALL_ASSETS.join('|') + ')' +
/:(?:([^:]+):)?([A-Za-z0-9_\-.]+)$/.source
);
function parseAsset(s) { function parseAsset(s) {
const m = ASSET_RE.exec(s); const m = ASSET_RE.exec(s);
if(m) { if(m) {
let result = { type : m[1] }; const result = { type : m[1] };
if(m[3]) { if(m[3]) {
result.location = m[2]; result.asset = m[3];
result.asset = m[3]; if(m[2]) {
result.location = m[2];
}
} else { } else {
result.asset = m[2]; result.asset = m[2];
} }
return result; return result;