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

Encode article title in WikiWho API access #188

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Api {
this.url,
subdomain,
'whocolor/v1.0.0-beta',
this.mwConfig.get( 'wgPageName' ),
encodeURIComponent( this.mwConfig.get( 'wgPageName' ) ),
// Always include the revision ID, to make sure we are always asking for
// the correct revision, whether the page was just edited, or, whether the
// page was edited by someone else while we were looking at the current page
Expand Down
11 changes: 10 additions & 1 deletion test/suite/Api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe( 'Api test', () => {
wgRevisionId: 234,
wgPageName: 'Iñtërnâtiônàlizætiøn_(disambig)'
},
expected: 'https://wikiwho.example.com/en/whocolor/v1.0.0-beta/Iñtërnâtiônàlizætiøn_(disambig)/234/'
expected: 'https://wikiwho.example.com/en/whocolor/v1.0.0-beta/I%C3%B1t%C3%ABrn%C3%A2ti%C3%B4n%C3%A0liz%C3%A6ti%C3%B8n_(disambig)/234/'
},
{
msg: 'Should only append a revision ID if it is not the current one',
Expand All @@ -32,6 +32,15 @@ describe( 'Api test', () => {
wgCurRevisionId: 456
},
expected: 'https://wikiwho.example.com/ru/whocolor/v1.0.0-beta/Foo/123/'
},
{
msg: 'Should encode query parameters',
config: {
wgServerName: 'en.wikipedia.org',
wgRevisionId: 123,
wgPageName: 'Test Works?user-ip=0.0.0.0&'
},
expected: 'https://wikiwho.example.com/en/whocolor/v1.0.0-beta/Test%20Works%3Fuser-ip%3D0.0.0.0%26/123/'
}
];

Expand Down
Loading