[PR #37] [MERGED] When removing a hostname results in an IP without hostname, delete the IP as well #44

Closed
opened 2026-03-02 05:08:19 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/goodhosts/hostsfile/pull/37
Author: @kaespi
Created: 4/9/2022
Status: Merged
Merged: 9/27/2022
Merged by: @luthermonson

Base: mainHead: remove-by-hostname-deletes-ip-if-needed


📝 Commits (1)

  • 3918b47 When removing a hostname results in an IP without hostname, delete the IP as well

📊 Changes

2 files changed (+60 additions, -6 deletions)

View changed files

📝 hosts.go (+34 -6)
📝 hosts_test.go (+26 -0)

📄 Description

I've noticed that when I delete a hostname using RemoveByHostname() I get lines in the hosts file which don't have a hostname, i.e. just an IP address. I think that's first of all not allowed and second doesn't make sense at all. Hence, I propose to remove the corresponding line completely when calling RemoveByHostname() removes the only hostname on a line.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/goodhosts/hostsfile/pull/37 **Author:** [@kaespi](https://github.com/kaespi) **Created:** 4/9/2022 **Status:** ✅ Merged **Merged:** 9/27/2022 **Merged by:** [@luthermonson](https://github.com/luthermonson) **Base:** `main` ← **Head:** `remove-by-hostname-deletes-ip-if-needed` --- ### 📝 Commits (1) - [`3918b47`](https://github.com/goodhosts/hostsfile/commit/3918b47e1c52a4be58943cb149ad990572ee801f) When removing a hostname results in an IP without hostname, delete the IP as well ### 📊 Changes **2 files changed** (+60 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `hosts.go` (+34 -6) 📝 `hosts_test.go` (+26 -0) </details> ### 📄 Description I've noticed that when I delete a hostname using `RemoveByHostname()` I get lines in the hosts file which don't have a hostname, i.e. just an IP address. I think that's first of all not allowed and second doesn't make sense at all. Hence, I propose to remove the corresponding line completely when calling `RemoveByHostname()` removes the only hostname on a line. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 05:08:19 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hostsfile#44
No description provided.