링크 추출 시 IP 주소(ex: http://127.0.0.1) 는 제외#163
Merged
reddevilmidzy merged 1 commit intomainfrom Jul 11, 2025
Merged
Conversation
7a3e858 to
164548f
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
The PR updates the link extractor to ignore links pointing to IP addresses (including localhost) during extraction.
- Renamed
REGEX_URLtoREGEX_DOMAINand addedREGEX_IP_ADDRESSto identify IP-based URLs. - Adjusted
find_link_in_contentto filter out matches that are IP addresses. - Added a new test
test_skip_ip_addressesand 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_pathinside the loop duplicates the same string multiple times. Consider cloning once outside or changing the signature to accept&strto 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(); |
There was a problem hiding this comment.
[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.
Owner
Author
There was a problem hiding this comment.
이건 다른 PR에서 할께요. PR 작게작게 가자.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
♟️ What’s this PR about?
간혹 테스트 용으로 127.0.0.1 과 같은 IP 주소를 코드에 작성하는 경우가 있다. 이런 경우 이 서비스가 체크해줄 필요가 없기 때문에 링크 추출 시 IP 주소는 건너뛰도록 구현하였습니다.
🔗 Related Issues / PRs
close: #162
(구현과 별개인 내용이지만, 확실히 작게 작게 작업을 분리하고 PR을 생성하는게 건강에 좋은 거 같다.)