Skip to content

Commit

Permalink
replace pubkey slice with regex
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenCappuccino authored and andyholmes committed May 2, 2023
1 parent 1539056 commit 3811161
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/flatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,19 @@ async function generateDescription(directory) {
if (core.getInput('gpg-sign')) {
const {stdout} = await exec.getExecOutput('gpg2',
['--armor', '--export', core.getInput('gpg-sign')]);
const publicKey = stdout.split('\n').slice(2, -2).join('');
/*
* Regex info:
* -{5}BEGIN.*-{5}
* ^ public key BEGIN header
* ([\w\s/+=]*)
* ^ capture the key (capture group 1)
* \s=[\w\s/+=]*
* ^ ignore the key checksum
* -{5}END.*-{5}
* ^ public key END header
*/
const regex = /-{5}BEGIN.*-{5}([\w\s/+=]*)\s=[\w\s/+=]*-{5}END.*-{5}/;
const publicKey = stdout.match(regex)[1].split('\n').join('');
metadata['GPGKey'] = publicKey;
}

Expand Down

0 comments on commit 3811161

Please sign in to comment.