diff --git a/src/core/Param.js b/src/core/Param.js index f63f11233..d3b843c3c 100644 --- a/src/core/Param.js +++ b/src/core/Param.js @@ -36,7 +36,7 @@ export default class Param { get(callback, failedCallback) { var paramClient = new Service({ ros: this.ros, - name: this.ros.namespace + 'rosapi/get_param', + name: `${this.ros.namespace}rosapi/get_param`, serviceType: 'rosapi/GetParam' }); diff --git a/src/core/Ros.js b/src/core/Ros.js index d6926ab0a..f46b1b110 100644 --- a/src/core/Ros.js +++ b/src/core/Ros.js @@ -46,9 +46,9 @@ export default class Ros extends EventEmitter { this.groovyCompatibility = options.groovyCompatibility ?? true; this.namespace = options.namespace || ''; - // Normalize namespace format: no leading slash, with trailing slash + // Normalize namespace format: with trailing slash if (this.namespace) { - this.namespace = this.namespace.replace(/^\//, '').replace(/\/?$/, '/'); + this.namespace = this.namespace.replace(/\/?$/, '/'); } // begin by checking if a URL was given diff --git a/test/namespaces.test.js b/test/namespaces.test.js index cc7f55fd9..c2a4b4055 100644 --- a/test/namespaces.test.js +++ b/test/namespaces.test.js @@ -125,4 +125,4 @@ describe('Namespaces', () => { expect(topics).not.hasLength(0); }) -}) \ No newline at end of file +})