Skip to content

Commit 3d11ba2

Browse files
chore(): Prepare release 4.0.2
1 parent dc9ed19 commit 3d11ba2

File tree

4 files changed

+47
-12
lines changed

4 files changed

+47
-12
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# Changelog
22

3+
## [4.0.2] - 2023-04-11
4+
5+
### Fixed
6+
7+
* Web: Parse url parameters for search and hash properly [#183](https://github.com/moberwasserlechner/capacitor-oauth2/pull/183), [#182](https://github.com/moberwasserlechner/capacitor-oauth2/issues/182). Thank you, [@jvartanian](https://github.com/jvartanian)
8+
39
## [4.0.1] - 2023-04-11
410

511
### Fixed
612

7-
* Android: Additional `id_token` argument for logout method [#192](https://github.com/moberwasserlechner/capacitor-oauth2/issues/233). Thank you [@svzi](https://github.com/svzi)
13+
* Android: Additional `id_token` argument for logout method [#233](https://github.com/moberwasserlechner/capacitor-oauth2/pull/233). Thank you, [@svzi](https://github.com/svzi)
814

915
### Chore
1016

@@ -133,7 +139,8 @@ This is controlled by Android specific parameters `handleResultOnNewIntent` for
133139
- Android: Fix Java compiler error #36 (thx @Anthbs)
134140
- Fix github security error by updating Jest lib
135141

136-
[Unreleased]: https://github.com/moberwasserlechner/capacitor-oauth2/compare/4.0.1...main
142+
[Unreleased]: https://github.com/moberwasserlechner/capacitor-oauth2/compare/4.0.2...main
143+
[4.0.2]: https://github.com/moberwasserlechner/capacitor-oauth2/compare/4.0.1...4.0.2
137144
[4.0.1]: https://github.com/moberwasserlechner/capacitor-oauth2/compare/4.0.0...4.0.1
138145
[4.0.0]: https://github.com/moberwasserlechner/capacitor-oauth2/compare/3.0.1...4.0.0
139146
[3.0.1]: https://github.com/moberwasserlechner/capacitor-oauth2/compare/3.0.0...3.0.1

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@byteowls/capacitor-oauth2",
3-
"version": "4.0.1",
3+
"version": "4.0.2",
44
"description": "Capacitor OAuth 2 client plugin",
55
"author": "Michael Oberwasserlechner",
66
"homepage": "https://github.com/moberwasserlechner/capacitor-oauth2",

src/web-utils.test.ts

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,31 +140,36 @@ describe('web options', () => {
140140

141141
describe("Url param extraction", () => {
142142

143-
it('should return null on null url', () => {
143+
it('should return undefined on null url', () => {
144144
const paramObj = WebUtils.getUrlParams(null!);
145145
expect(paramObj).toBeUndefined();
146146
});
147147

148-
it('should return null on empty url', () => {
148+
it('should return undefined on empty url', () => {
149149
const paramObj = WebUtils.getUrlParams("");
150150
expect(paramObj).toBeUndefined();
151151
});
152152

153-
it('should return null on url with spaces', () => {
153+
it('should return undefined on url with spaces', () => {
154154
const paramObj = WebUtils.getUrlParams(" ");
155155
expect(paramObj).toBeUndefined();
156156
});
157157

158-
it('should return null if no params in url', () => {
158+
it('should return undefined if no params in url', () => {
159159
const paramObj = WebUtils.getUrlParams("https://app.example.com/");
160160
expect(paramObj).toBeUndefined();
161161
});
162162

163-
it('should return null if no params in url', () => {
163+
it('should return undefined if no params in url search', () => {
164164
const paramObj = WebUtils.getUrlParams("https://app.example.com?");
165165
expect(paramObj).toBeUndefined();
166166
});
167167

168+
it('should return undefined if no params in url hash', () => {
169+
const paramObj = WebUtils.getUrlParams("https://app.example.com#");
170+
expect(paramObj).toBeUndefined();
171+
});
172+
168173
it('should remove invalid combinations one param', () => {
169174
const paramObj = WebUtils.getUrlParams("https://app.example.com?=test");
170175
expect(paramObj).toBeUndefined();
@@ -182,7 +187,7 @@ describe("Url param extraction", () => {
182187

183188
it('should extract a uuid state param', () => {
184189
const state = WebUtils.randomString();
185-
const paramObj = WebUtils.getUrlParams("https://app.example.com?state=" + state + "&access_token=testtoken");
190+
const paramObj = WebUtils.getUrlParams(`https://app.example.com?state=${state}&access_token=testtoken`);
186191
expect(paramObj!["state"]).toStrictEqual(state);
187192
});
188193

@@ -191,7 +196,15 @@ describe("Url param extraction", () => {
191196
const foo = WebUtils.randomString();
192197
const paramObj = WebUtils.getUrlParams(`https://app.example.com?random=${random}&foo=${foo}#ignored`);
193198
expect(paramObj!["random"]).toStrictEqual(random);
194-
expect(paramObj!["foo"]).toStrictEqual(`${foo}`);
199+
expect(paramObj!["foo"]).toStrictEqual(foo);
200+
});
201+
202+
it('should use query flag with another question mark in a param', () => {
203+
const random = WebUtils.randomString();
204+
const foo = WebUtils.randomString();
205+
const paramObj = WebUtils.getUrlParams(`https://app.example.com?random=${random}&foo=${foo}?questionmark`);
206+
expect(paramObj!["random"]).toStrictEqual(random);
207+
expect(paramObj!["foo"]).toStrictEqual(`${foo}?questionmark`);
195208
});
196209

197210
it('should use hash flag and ignore query flag', () => {
@@ -202,6 +215,14 @@ describe("Url param extraction", () => {
202215
expect(paramObj!["foo"]).toStrictEqual(`${foo}?ignored`);
203216
});
204217

218+
it('should use hash flag with another hash in a param', () => {
219+
const random = WebUtils.randomString();
220+
const foo = WebUtils.randomString();
221+
const paramObj = WebUtils.getUrlParams(`https://app.example.com#random=${random}&foo=${foo}#hash`);
222+
expect(paramObj!["random"]).toStrictEqual(random);
223+
expect(paramObj!["foo"]).toStrictEqual(`${foo}#hash`);
224+
});
225+
205226
it('should extract hash params correctly', () => {
206227
const random = WebUtils.randomString(20);
207228
const url = `http://localhost:4200/#state=${random}&access_token=ya29.a0ARrdaM-sdfsfsdfsdfsdfs-YGFHwg_lM6dePPaT_TunbpsdfsdfsdfsEG6vTVLsLJDDW
@@ -213,6 +234,13 @@ describe("Url param extraction", () => {
213234
expect(paramObj!["prompt"]).toBeDefined();
214235
expect(paramObj!["state"]).toStrictEqual(random);
215236
});
237+
238+
it('should extract hash params if search param indicator present', () => {
239+
const token = "sldfskdjflsdf12302";
240+
const url = `http://localhost:3000/login?#access_token=${token}`;
241+
const paramObj = WebUtils.getUrlParams(url);
242+
expect(paramObj!["access_token"]).toStrictEqual(token);
243+
})
216244
});
217245

218246
describe("Random string gen", () => {

0 commit comments

Comments
 (0)