Skip to content

Commit

Permalink
fix(backend-github-graphql): handle trailing paths in collection fold…
Browse files Browse the repository at this point in the history
…er (#3099)
  • Loading branch information
erezrokah committed Jan 16, 2020
1 parent 6a13a85 commit bc80804
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/netlify-cms-backend-github/src/GraphQLAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
localForage,
DEFAULT_PR_BODY,
} from 'netlify-cms-lib-util';
import { trim } from 'lodash';
import introspectionQueryResultData from './fragmentTypes';
import API, { Config, BlobArgs, PR, API_NAME } from './API';
import * as queries from './queries';
Expand Down Expand Up @@ -250,13 +251,14 @@ export default class GraphQLAPI extends API {

async listFiles(path: string, { repoURL = this.repoURL, branch = this.branch, depth = 1 } = {}) {
const { owner, name } = this.getOwnerAndNameFromRepoUrl(repoURL);
const folder = trim(path, '/');
const { data } = await this.query({
query: queries.files(depth),
variables: { owner, name, expression: `${branch}:${path}` },
variables: { owner, name, expression: `${branch}:${folder}` },
});

if (data.repository.object) {
const allFiles = this.getAllFiles(data.repository.object.entries, path);
const allFiles = this.getAllFiles(data.repository.object.entries, folder);
return allFiles;
} else {
return [];
Expand Down

0 comments on commit bc80804

Please sign in to comment.