Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function getServiceName(serviceConfig: ServiceConfig) {
}

export function getApiPath(apiId: string) {
return apiId.replace(/\.v.*/, '').replace(/\./g, '/');
return apiId.replace(/\.v[0-9].*/, '').replace(/\./g, '/');
}

export function getApiPathWithDashes(apiId: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,36 @@ const octokit = new Octokit({

describe('get bootstrap template vars', () => {
describe('tests for metadata information', () => {
it('should return the API path without the version, with slashes', async () => {
assert.deepStrictEqual(
getApiPath('cloud.google.kms.v1'),
'cloud/google/kms',
);
describe('getApiPath', () => {
it('should return without the version, with slashes', async () => {
assert.deepStrictEqual(
getApiPath('cloud.google.kms.v1'),
'cloud/google/kms',
);
});

it('should preserve package names that start with v', async () => {
assert.deepStrictEqual(
getApiPath('cloud.google.visionai.v1'),
'cloud/google/visionai',
);
});
});

it('should return the API path without the version, with dashes', async () => {
assert.deepStrictEqual(
getApiPathWithDashes('cloud.google.kms.v1'),
'cloud-google-kms',
);
describe('getApiPathWithDashes', () => {
it('should return without the version, with dashes', async () => {
assert.deepStrictEqual(
getApiPathWithDashes('cloud.google.kms.v1'),
'cloud-google-kms',
);
});

it('should preserve names that start with v', async () => {
assert.deepStrictEqual(
getApiPathWithDashes('cloud.google.visionai.v1'),
'cloud-google-visionai',
);
});
});

it('should get just the version', async () => {
Expand Down
Loading