File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
packages/packages/google-gax Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ export interface Segment {
3434}
3535
3636export interface Bindings {
37- [ index : string ] : string ;
37+ [ index : string ] : string | number ;
3838}
3939
4040export class PathTemplate {
@@ -129,7 +129,7 @@ export class PathTemplate {
129129 ) ;
130130 throw new TypeError ( msg ) ;
131131 }
132- const tmp = new PathTemplate ( bindings [ segment . literal ] ) ;
132+ const tmp = new PathTemplate ( bindings [ segment . literal ] . toString ( ) ) ;
133133 Array . prototype . push . apply ( out , tmp . segments ) ;
134134 inABinding = true ;
135135 } else if ( segment . kind === extras . END_BINDING ) {
Original file line number Diff line number Diff line change @@ -139,6 +139,18 @@ describe('PathTemplate', () => {
139139 const want = 'bar/1/2/foo/3' ;
140140 expect ( template . render ( params ) ) . to . eql ( want ) ;
141141 } ) ;
142+
143+ it ( 'should accept both strings and numbers as values' , ( ) => {
144+ const template = new PathTemplate (
145+ 'projects/{project}/sessions/{session}'
146+ ) ;
147+ const params = {
148+ project : 'testProject' ,
149+ session : 123 ,
150+ } ;
151+ const want = 'projects/testProject/sessions/123' ;
152+ expect ( template . render ( params ) ) . to . eql ( want ) ;
153+ } ) ;
142154 } ) ;
143155
144156 describe ( 'method `inspect`' , ( ) => {
You can’t perform that action at this time.
0 commit comments