mirror of
https://github.com/zhigang1992/probot.git
synced 2026-06-18 15:29:03 +08:00
8 lines
305 B
JavaScript
8 lines
305 B
JavaScript
const REGEX = /^(?:([\w-]+)\/([\w-]+):)?([^#]*)(?:#(.*))?$/;
|
|
|
|
// Parses paths in the form of `owner/repo:path/to/file#ref`
|
|
module.exports = function (url, source) {
|
|
const [, owner, repo, path, ref] = url.match(REGEX);
|
|
return Object.assign({}, source, {path}, owner && {owner, repo}, ref && {ref});
|
|
};
|