fix(backend-git-gateway): re-write GitHub pagination links (#3135)
This commit is contained in:
committed by
Shawn Erquhart
parent
48afa8dfe4
commit
834f6b9e45
@ -95,4 +95,8 @@ export default class API extends GithubAPI {
|
||||
body: JSON.stringify(commitParams),
|
||||
});
|
||||
}
|
||||
|
||||
nextUrlProcessor() {
|
||||
return (url: string) => url.replace(/^(?:[a-z]+:\/\/.+?\/.+?\/.+?\/)/, `${this.apiRoot}/`);
|
||||
}
|
||||
}
|
||||
|
@ -84,4 +84,16 @@ describe('github API', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('nextUrlProcessor', () => {
|
||||
it('should re-write github url', () => {
|
||||
const api = new API({
|
||||
apiRoot: 'https://site.netlify.com/.netlify/git/github',
|
||||
});
|
||||
|
||||
expect(api.nextUrlProcessor()('https://api.github.com/repositories/10000/pulls')).toEqual(
|
||||
'https://site.netlify.com/.netlify/git/github/pulls',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user