Skip to content
Merged
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
6 changes: 4 additions & 2 deletions src/cloudFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ export class CloudFunction {
`The expected data format should be "KEY1=VALUE1", got "${pair}" while parsing "${values}"`,
);
}
const keyValue = pair.split('=');
kvPairs[keyValue[0]] = keyValue[1];
// Split on the first delimiter only
const name = pair.substring(0, pair.indexOf('='));
const value = pair.substring(pair.indexOf('=') + 1);
kvPairs[name] = value;
});
return kvPairs;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/cloudFunction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ describe('CloudFunction', function () {
);
});

it('creates a http function with two envVars containing equals character', function () {
const envVars = 'KEY1=VALUE=1,KEY2=VALUE=2';
const cf = new CloudFunction({ name, runtime, parent, envVars });
expect(cf.request.name).equal(`${parent}/functions/${name}`);
expect(cf.request.runtime).equal(runtime);
expect(cf.request.httpsTrigger).not.to.be.null;
expect(cf.request.environmentVariables?.KEY1).equal('VALUE=1');
expect(cf.request.environmentVariables?.KEY2).equal('VALUE=2');
});

it('creates a http function with envVarsFile', function () {
const envVarsFile = 'tests/env-var-files/test.good.yaml';
const cf = new CloudFunction({ name, runtime, parent, envVarsFile });
Expand Down