mirror of
https://github.com/bower/bower.git
synced 2026-02-12 06:55:04 -05:00
18 lines
449 B
JavaScript
18 lines
449 B
JavaScript
var createError = require('./createError');
|
|
|
|
function decomposeEndpoint(endpoint) {
|
|
var regExp = /^(?:([\w\-]|(?:[\w\.\-]+[\w\-])?)\|)?([^\|#]+)(?:#(.*))?$/;
|
|
var matches = endpoint.match(regExp);
|
|
|
|
if (!matches) {
|
|
throw createError('Invalid endpoint: "' + endpoint + '"', 'EINVEND');
|
|
}
|
|
|
|
return {
|
|
name: matches[1],
|
|
source: matches[2],
|
|
target: matches[3]
|
|
};
|
|
}
|
|
|
|
module.exports = decomposeEndpoint; |