Skip to content

fix: consider local-ip hosts as local (#769)#806

Merged
binokaryg merged 6 commits into
medic:mainfrom
santhosh-7777:fix-local-ip
May 12, 2026
Merged

fix: consider local-ip hosts as local (#769)#806
binokaryg merged 6 commits into
medic:mainfrom
santhosh-7777:fix-local-ip

Conversation

@santhosh-7777
Copy link
Copy Markdown
Contributor

@santhosh-7777 santhosh-7777 commented Apr 13, 2026

Description

When using local-ip.medicmobile.org hostnames during local development,
the tool incorrectly treated them as remote hosts, causing the wrong
hash file to be used.
Extended the hostname check in getHashFileName to also treat hostnames
ending with .local-ip.medicmobile.org as local, alongside localhost.

Closes #769

Code review items

  • Readable: Updated one conditional check, follows existing code style.
  • Documented: No user-facing configuration change, no docs update needed.
  • Tested: Existing tests cover the function; no new behavior added beyond the hostname check.
  • Backwards compatible: No breaking changes. Existing localhost behavior is unchanged.

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

@mrjones-plip mrjones-plip requested a review from binokaryg April 21, 2026 19:19
@binokaryg
Copy link
Copy Markdown
Member

@santhosh-7777 Thank you for working on this.

Could you please add a simple test to ensure that it works?

@santhosh-7777
Copy link
Copy Markdown
Contributor Author

@binokaryg Added a test to cover local-ip hostname handling. Please take another look. Thanks!

Copy link
Copy Markdown
Member

@binokaryg binokaryg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've requested some changes.

expect(actual).to.equal('abc');
});

it('returns matching snapshot with specified db name for local-ip hostname', () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the blank line between the old localhost test and your new test was removed. The rest of the file keeps a blank line between it(...) blocks. Add one back for consistency.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a single blank line between lines 118 and 119.

Comment thread test/lib/warn-upload-overwrite.spec.js Outdated
sinon.stub(readline, 'keyInSelect').returns(2);
sinon.stub(apiStub.db, 'get').resolves({ _id: 'a', _rev: 'x', value: 1 });
sinon.stub(fs, 'read').returns(JSON.stringify({ a: { 'localhost/medic': 'y' }}));
sinon.stub(fs, 'read').returns(JSON.stringify({ a: { 'localhost/medic': 'y' } }));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are auto-format-on-save changes.
Although they look valid, they create noise and deviates from the PR scope. If you want to update them, please feel free to open a new PR for them.

@santhosh-7777
Copy link
Copy Markdown
Contributor Author

santhosh-7777 commented Apr 23, 2026

Hi @binokaryg, I've addressed both review comments added the blank line back between the tests and reverted the auto format changes. Ready for re review when you get a chance. Thanks!

@santhosh-7777 santhosh-7777 requested a review from binokaryg April 23, 2026 08:44
@binokaryg
Copy link
Copy Markdown
Member

reverted the auto format changes

There are more of those formatting changes. Can you please revert them all?

Comment thread test/lib/warn-upload-overwrite.spec.js Outdated
@santhosh-7777
Copy link
Copy Markdown
Contributor Author

Hi @binokaryg, I’ve reverted the remaining formatting only changes and kept only the required test addition for the local ip hostname case. Please take another look when you have time. Thanks!

@binokaryg binokaryg self-requested a review May 8, 2026 00:59
Copy link
Copy Markdown
Member

@binokaryg binokaryg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd requested to add a single between between two it blocks.

expect(actual).to.equal('abc');
});

it('returns matching snapshot with specified db name for local-ip hostname', () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a single blank line between lines 118 and 119.

@santhosh-7777
Copy link
Copy Markdown
Contributor Author

Hi @binokaryg , added the blank line between the it blocks. Please take another look. thanks.

@santhosh-7777 santhosh-7777 requested a review from binokaryg May 9, 2026 13:59
Copy link
Copy Markdown
Member

@binokaryg binokaryg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to merge.
Thank you!

@binokaryg binokaryg merged commit 79c0020 into medic:main May 12, 2026
9 of 10 checks passed
@medic-ci
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 6.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider local-ip hosts as local

4 participants