Files
probot/lib/util/github-url.js
2016-12-08 23:54:22 -06:00

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});
};