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

Resolved fetching revisions from wikisource.org #5592

Merged
merged 4 commits into from
Jan 25, 2024

Conversation

omChauhanDev
Copy link
Contributor

What this PR does

Fixes #5530
This PR resolves the CORS error that is occurring while fetching revisions from wikisource.org

Screenshots

Before:

Before

After:

After

@omChauhanDev
Copy link
Contributor Author

@ragesoss Any idea why it appending .org twice at the end of wikidata.

Screenshot from 2024-01-24 00-47-33

@ragesoss
Copy link
Member

Probably comes from a call to Wiki#domain, as defined in wiki.rb. If a change to the wiki object is making it to the backend, that's probably a mistake; I would expect this issue to be limited to data and code on the JS side of the app.

@omChauhanDev
Copy link
Contributor Author

Okay, all js tests are passing.

@ragesoss
Copy link
Member

I'm not sure. If it's throwing a new error on the back end, then it's probably an unintended side effect of the frontend change you made that is causing unexpected data to reach the backend.

This should probably also include a test that exercises the now-working fetching of wikisource.org.

Now that I think about it again, I'm not certain that a correct solution won't involve a backend change, for example, to ensure that the domain itself is passed along for each Wiki that the frontend deals with. It might be that we need to use a domain supplied by the backend for making queries, rather than using the toWikiDomain function. Either than, or the function will need to deal specifically with the case of wikidata.org.

@omChauhanDev
Copy link
Contributor Author

@ragesoss i resolved all those previous errors just my modifying the logic of toWikiDomain as you expected earlier that this issue is only related to js side of app . Now only one test is failing but this test is also failing before doing any changes in code (like in master also).

After Doing Changes :

Screenshot from 2024-01-24 16-38-07

In Master Also :

image

const subdomain = wiki.language || 'www';
return `${subdomain}.${wiki.project}.org`;
const language = (wiki.language) ? `${wiki.language}.` : 'www.';
const subdomain = (wiki.project === 'wikisource' && !wiki.language) ? '' : language;
Copy link
Member

Choose a reason for hiding this comment

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

Include a comment here to explain why we have to special-case wikisource.org.

@ragesoss
Copy link
Member

Great. Sounds like the failing test is unrelated; I'll look into that. I would also like this PR to include a new test that would have caught the bug before the toWikiDomain change.

@omChauhanDev
Copy link
Contributor Author

Sure, I have added a new js test which will take care of previous bug in "toWikiDomain" function.

Screenshot

New test with old function
image

New test after modifying function
image

@ragesoss
Copy link
Member

Looks good, thanks!

@ragesoss ragesoss merged commit 2461acf into WikiEducationFoundation:master Jan 25, 2024
1 check failed
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.

Activity tab does cannot fetch revisions from wikisource.org
2 participants