Skip to content

링크 추출 시 IP 주소(ex: http://127.0.0.1) 는 제외#163

Merged
reddevilmidzy merged 1 commit intomainfrom
skip-ip-addr
Jul 11, 2025
Merged

링크 추출 시 IP 주소(ex: http://127.0.0.1) 는 제외#163
reddevilmidzy merged 1 commit intomainfrom
skip-ip-addr

Conversation

@reddevilmidzy
Copy link
Owner

@reddevilmidzy reddevilmidzy commented Jul 11, 2025

♟️ What’s this PR about?

간혹 테스트 용으로 127.0.0.1 과 같은 IP 주소를 코드에 작성하는 경우가 있다. 이런 경우 이 서비스가 체크해줄 필요가 없기 때문에 링크 추출 시 IP 주소는 건너뛰도록 구현하였습니다.

🔗 Related Issues / PRs

close: #162

(구현과 별개인 내용이지만, 확실히 작게 작게 작업을 분리하고 PR을 생성하는게 건강에 좋은 거 같다.)

Copilot AI review requested due to automatic review settings July 11, 2025 16:38
@github-actions github-actions bot added this to the 5차 MVP 구현 milestone Jul 11, 2025

This comment was marked as outdated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

The PR updates the link extractor to ignore links pointing to IP addresses (including localhost) during extraction.

  • Renamed REGEX_URL to REGEX_DOMAIN and added REGEX_IP_ADDRESS to identify IP-based URLs.
  • Adjusted find_link_in_content to filter out matches that are IP addresses.
  • Added a new test test_skip_ip_addresses and updated existing tests to use the renamed regex.
Comments suppressed due to low confidence (2)

rook/src/git/link_extractor.rs:133

  • [nitpick] It would be helpful to add a test case where both domain and IP links appear together, to ensure domain links are still captured when IP skipping is enabled.
    #[test]

rook/src/git/link_extractor.rs:86

  • [nitpick] Cloning file_path inside the loop duplicates the same string multiple times. Consider cloning once outside or changing the signature to accept &str to reduce allocations.
                file_path: file_path.clone(),


fn find_link_in_content(content: &str, file_path: String) -> HashSet<LinkInfo> {
let url_regex = Regex::new(REGEX_URL).unwrap();
let domain_regex = Regex::new(REGEX_DOMAIN).unwrap();
Copy link

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

[nitpick] Compiling these regexes on every call can be costly. Consider moving Regex::new(...) into a lazy static (e.g., with once_cell or lazy_static) so they're compiled only once.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

이건 다른 PR에서 할께요. PR 작게작게 가자.

@reddevilmidzy reddevilmidzy merged commit d98c1bc into main Jul 11, 2025
5 checks passed
@reddevilmidzy reddevilmidzy deleted the skip-ip-addr branch July 11, 2025 17:52
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

Successfully merging this pull request may close these issues.

도메인이 아닌 IP 주소 예외처리

2 participants