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

Bug: Nodes not added to ProxyObject with root path ("/") #122

Open
bspot opened this issue Mar 19, 2023 · 0 comments
Open

Bug: Nodes not added to ProxyObject with root path ("/") #122

bspot opened this issue Mar 19, 2023 · 0 comments

Comments

@bspot
Copy link

bspot commented Mar 19, 2023

When creating a ProxyObject at the root path, i.e.

const obj = await bus.getProxyObject('some.service.name', '/');

the sub-nodes contained in the XML returned by the introspect call will not be added to the ProxyObject's nodes attribute.

That is because of how the sub-nodes full object path is constructed in https://github.com/dbusjs/node-dbus-next/blob/master/lib/client/proxy-object.js#L95

const path = `${this.path}/${name}`;
if (isObjectPathValid(path)) {
  this.nodes.push(path);
}

Since this.path is /, the sub-nodes path will start with //, which is not a valid object path and therefore rejected by the following isObjectPathValid check.

I think this could be replaced with

const path = this.path === '/' ? `/${name}` : `${this.path}/${name}`;

since otherwise object paths can not end with '/'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant