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

Utterances will not match to URLs exactly #661

Open
ericswpark opened this issue Sep 5, 2023 · 4 comments
Open

Utterances will not match to URLs exactly #661

ericswpark opened this issue Sep 5, 2023 · 4 comments

Comments

@ericswpark
Copy link

I have two blog sections on my website:

The first link is for the English version of my website, while the second one is for the Korean version. As the audience for these two blogs speak different languages, it makes sense to separate the comments section as well.

However, Utterances is mixing the two comment sections, even though I'm using the url mapping option. For example, see: https://ericswpark.com/blog/2020/2020-10-11-porting-samsungs-galaxy-note-3-neo/ Even though the blog is in the English version, it is pulling up the Korean comment section with the issue title of https://ericswpark.com/ko/blog/2020/2020-10-11-porting-samsungs-galaxy-note-3-neo/

@Duncanma
Copy link

I think this is because GitHub is not doing an exact string match on issues... you can try the query yourself

https://github.com/ericswpark/ericswpark.github.io-comments/issues?q=is%3Aissue+in%3Atitle+%22https%3A%2F%2Fericswpark.com%2Fblog%2F2020%2F2020-10-11-porting-samsungs-galaxy-note-3-neo%2F%22+

To see that it returns the /ko/ ones when searching with the non-ko URL.

I'm also thinking it is treating the / and - characters as whitespace... so it is really searching for any issues with the following strings

https ericswpark.com blog 2020 2020 10 11 porting samsungs galaxy note 3 neo

To fix, I would say it might work if the URL was condensed into a single string both when the 1st issue is posted and when searching.... so something like "ericswpark.comblog202020201011portingsamsungsgalaxynote3neo"

Or a hash of the URL? a MD5 hash of the non-ko post would be 40b39569eb54ed2e4e29175a9343914c and the ko one would be cd1d3eb3b0ff6da17ac4c0924bda8ab7

@ericswpark
Copy link
Author

I think the OP should have some hash of the URL that utterances could compare against, to make sure that the correct thread is fetched.

@ericswpark
Copy link
Author

Think I found the relevant part:

export function loadIssueByTerm(term: string) {

This function should check if the response returned from the GitHub API has a matching title:

Screenshot 2023-12-11 at 3 47 50 PM

@ericswpark
Copy link
Author

Actually, seems like title matching is already done:
Screenshot 2023-12-11 at 3 50 27 PM

if (result.title.toLowerCase().indexOf(term) !== -1) {

console.warn(`Issue search results do not contain an issue with title matching "${term}". Using first result.`);

So the only change needed is to not blindly return the first result when none of the titles match, and seems like there's already a PR open for that: #496

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

No branches or pull requests

2 participants