format upload url

This commit is contained in:
softprops 2021-08-07 18:33:23 -04:00
parent 11282f4ee9
commit d9cc08588c
4 changed files with 25 additions and 3 deletions

View file

@ -4,11 +4,22 @@ import {
paths, paths,
parseConfig, parseConfig,
parseInputFiles, parseInputFiles,
unmatchedPatterns unmatchedPatterns,
uploadUrl
} from "../src/util"; } from "../src/util";
import * as assert from "assert"; import * as assert from "assert";
describe("util", () => { describe("util", () => {
describe("uploadUrl", () => {
it("stripts template", () => {
assert.equal(
uploadUrl(
"https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}"
),
"https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets"
);
});
});
describe("parseInputFiles", () => { describe("parseInputFiles", () => {
it("parses empty strings", () => { it("parses empty strings", () => {
assert.deepStrictEqual(parseInputFiles(""), []); assert.deepStrictEqual(parseInputFiles(""), []);

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View file

@ -144,7 +144,10 @@ export const upload = async (
method: "POST", method: "POST",
body body
}); });
return resp.json(); console.log(`resp`, resp);
const json = await resp.json();
console.log(`body`, json);
return json;
// return await gh.rest.repos.uploadReleaseAsset({ // return await gh.rest.repos.uploadReleaseAsset({
// url, // url,

View file

@ -18,6 +18,14 @@ export interface Config {
input_target_commitish?: string; input_target_commitish?: string;
} }
export const uploadUrl = (url: string): string => {
const templateMarkerPos = url.indexOf("{");
if (templateMarkerPos > -1) {
return url.substring(0, templateMarkerPos);
}
return url;
};
export const releaseBody = (config: Config): string | undefined => { export const releaseBody = (config: Config): string | undefined => {
return ( return (
(config.input_body_path && (config.input_body_path &&