Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not replace projectId on stream objects #53

Merged
merged 1 commit into from
Nov 14, 2018
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
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {Stream} from 'stream';

/**
* Copyright 2014 Google Inc. All Rights Reserved.
*
Expand Down Expand Up @@ -30,7 +32,7 @@ export function replaceProjectIdToken(value: any, projectId: string): any {
}

if (value !== null && typeof value === 'object' &&
!(value instanceof Buffer) &&
!(value instanceof Buffer) && !(value instanceof Stream) &&
typeof value.hasOwnProperty === 'function') {
for (const opt in value) {
if (value.hasOwnProperty(opt)) {
Expand Down
10 changes: 10 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import * as assert from 'assert';
import * as stream from 'stream';
import {replaceProjectIdToken} from '../src';

describe('projectId placeholder', () => {
Expand Down Expand Up @@ -110,4 +111,13 @@ describe('projectId placeholder', () => {
},
replaced);
});

it('should not inject projectId into stream', () => {
// tslint:disable-next-line: no-any
const transform = new stream.Transform() as any;
transform.prop = 'A {{projectId}} Z';

const replaced = replaceProjectIdToken(transform, PROJECT_ID);
assert.deepEqual(transform.prop, replaced.prop);
});
});