UNPKG

hhurley

Version:

Tool to find lost security patches for Linux distributions.

38 lines (22 loc) 842 B
/* Copyright IBM Research Emergent Solutions Jesús Pérez <jesusprubio@gmail.com> This code may only be used under the MIT license found at https://opensource.org/licenses/MIT. */ 'use strict'; const utils = require('../utils'); const substrs = ['github.com', '/commit/']; module.exports.match = str => utils.every(substrs, (substr) => { const pos = str.search(substr); if (pos !== -1) { return true; } return false; }); // Sometimes they include the link to the "diff" instead the commit, ie: // 'https://github.com/vadz/libtiff/commit/83a4b92815ea04969d4944 // 16eaae3d4c6b338e4a#diff-c8b4b355f9b5c06d585b23138e1c185f' module.exports.massage = str => `${str.split('#')[0]}.patch`; module.exports.getHash = (str) => { const split = str.split('#')[0].split('/'); return split[split.length - 1]; };