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

Fix suggestion for image link checker #2163

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

Eric-Arellano
Copy link
Collaborator

Closes #2159.

This change also results in more suggestions happening than we had before, as shown in the tests.

let score = levenshtein.get(pathNoExtension, file.path);
const candidatePath = file.path.startsWith("public/")
? file.path.replace(/^public/, "")
: file.path.replace(/\.[^\/.]+$/, "").replace(/^docs/, "");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The first replace removes the file extension, which would be wrong to do for public/.

const candidatePath = file.path.startsWith("public/")
? file.path.replace(/^public/, "")
: file.path.replace(/\.[^\/.]+$/, "").replace(/^docs/, "");
let score = levenshtein.get(this.value, candidatePath);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this.value is the problematic link. The anchor is stripped and stored separately in this.anchor.

Copy link
Member

@frankharkins frankharkins left a comment

Choose a reason for hiding this comment

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

Nice, deduplicated some code too

@Eric-Arellano Eric-Arellano added this pull request to the merge queue Oct 22, 2024
Merged via the queue into main with commit bd93f3a Oct 22, 2024
3 checks passed
@Eric-Arellano Eric-Arellano deleted the EA/fix-suggestion-for-image-link-checker branch October 22, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Misleading error message suggestion for photos in internal link checker
2 participants