Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
2cbc475e
Commit
2cbc475e
authored
Nov 27, 2018
by
Scott Escue
Committed by
Mike Greiling
Jan 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing static analysis issues
parent
a3541a8d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
10 deletions
+36
-10
app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js
...s/javascripts/pages/sessions/new/preserve_url_fragment.js
+6
-3
spec/javascripts/lib/utils/url_utility_spec.js
spec/javascripts/lib/utils/url_utility_spec.js
+15
-2
spec/javascripts/oauth_remember_me_spec.js
spec/javascripts/oauth_remember_me_spec.js
+4
-2
spec/javascripts/pages/sessions/new/preserve_url_fragment_spec.js
...ascripts/pages/sessions/new/preserve_url_fragment_spec.js
+11
-3
No files found.
app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js
View file @
2cbc475e
...
...
@@ -13,7 +13,7 @@ export default function preserveUrlFragment(fragment) {
// Append the fragment to all sign-in/sign-up form actions so it is preserved when the user is
// eventually redirected back to the originally requested URL.
const
forms
=
document
.
querySelectorAll
(
'
#signin-container form
'
);
Array
.
prototype
.
forEach
.
call
(
forms
,
(
form
)
=>
{
Array
.
prototype
.
forEach
.
call
(
forms
,
form
=>
{
const
actionWithFragment
=
setUrlFragment
(
form
.
getAttribute
(
'
action
'
),
`#
${
normalFragment
}
`
);
form
.
setAttribute
(
'
action
'
,
actionWithFragment
);
});
...
...
@@ -21,8 +21,11 @@ export default function preserveUrlFragment(fragment) {
// Append a redirect_fragment query param to all oauth provider links. The redirect_fragment
// query param will be available in the omniauth callback upon successful authentication
const
anchors
=
document
.
querySelectorAll
(
'
#signin-container a.oauth-login
'
);
Array
.
prototype
.
forEach
.
call
(
anchors
,
(
anchor
)
=>
{
const
newHref
=
mergeUrlParams
({
redirect_fragment
:
normalFragment
},
anchor
.
getAttribute
(
'
href
'
));
Array
.
prototype
.
forEach
.
call
(
anchors
,
anchor
=>
{
const
newHref
=
mergeUrlParams
(
{
redirect_fragment
:
normalFragment
},
anchor
.
getAttribute
(
'
href
'
),
);
anchor
.
setAttribute
(
'
href
'
,
newHref
);
});
}
...
...
spec/javascripts/lib/utils/url_utility_spec.js
View file @
2cbc475e
...
...
@@ -32,8 +32,13 @@ describe('URL utility', () => {
expect
(
urlUtils
.
mergeUrlParams
({
w
:
1
},
'
#frag
'
)).
toBe
(
'
?w=1#frag
'
);
expect
(
urlUtils
.
mergeUrlParams
({
w
:
1
},
'
/path#frag
'
)).
toBe
(
'
/path?w=1#frag
'
);
expect
(
urlUtils
.
mergeUrlParams
({
w
:
1
},
'
https://host/path
'
)).
toBe
(
'
https://host/path?w=1
'
);
expect
(
urlUtils
.
mergeUrlParams
({
w
:
1
},
'
https://host/path#frag
'
)).
toBe
(
'
https://host/path?w=1#frag
'
);
expect
(
urlUtils
.
mergeUrlParams
({
w
:
1
},
'
https://h/p?k1=v1#frag
'
)).
toBe
(
'
https://h/p?k1=v1&w=1#frag
'
);
expect
(
urlUtils
.
mergeUrlParams
({
w
:
1
},
'
https://host/path#frag
'
)).
toBe
(
'
https://host/path?w=1#frag
'
,
);
expect
(
urlUtils
.
mergeUrlParams
({
w
:
1
},
'
https://h/p?k1=v1#frag
'
)).
toBe
(
'
https://h/p?k1=v1&w=1#frag
'
,
);
});
it
(
'
updates w
'
,
()
=>
{
...
...
@@ -59,21 +64,25 @@ describe('URL utility', () => {
it
(
'
should remove param when url has no other params
'
,
()
=>
{
const
url
=
urlUtils
.
removeParams
([
'
size
'
],
'
/feature/home?size=5
'
);
expect
(
url
).
toBe
(
'
/feature/home
'
);
});
it
(
'
should remove param when url has other params
'
,
()
=>
{
const
url
=
urlUtils
.
removeParams
([
'
size
'
],
'
/feature/home?q=1&size=5&f=html
'
);
expect
(
url
).
toBe
(
'
/feature/home?q=1&f=html
'
);
});
it
(
'
should remove param and preserve fragment
'
,
()
=>
{
const
url
=
urlUtils
.
removeParams
([
'
size
'
],
'
/feature/home?size=5#H2
'
);
expect
(
url
).
toBe
(
'
/feature/home#H2
'
);
});
it
(
'
should remove multiple params
'
,
()
=>
{
const
url
=
urlUtils
.
removeParams
([
'
z
'
,
'
a
'
],
'
/home?z=11111&l=en_US&a=true#H2
'
);
expect
(
url
).
toBe
(
'
/home?l=en_US#H2
'
);
});
});
...
...
@@ -87,6 +96,7 @@ describe('URL utility', () => {
});
const
url
=
urlUtils
.
removeParams
([
'
locale
'
]);
expect
(
url
).
toBe
(
'
https://mysite.com/?zip=11111&ads=false#privacy
'
);
});
});
...
...
@@ -95,16 +105,19 @@ describe('URL utility', () => {
describe
(
'
setUrlFragment
'
,
()
=>
{
it
(
'
should set fragment when url has no fragment
'
,
()
=>
{
const
url
=
urlUtils
.
setUrlFragment
(
'
/home/feature
'
,
'
usage
'
);
expect
(
url
).
toBe
(
'
/home/feature#usage
'
);
});
it
(
'
should set fragment when url has existing fragment
'
,
()
=>
{
const
url
=
urlUtils
.
setUrlFragment
(
'
/home/feature#overview
'
,
'
usage
'
);
expect
(
url
).
toBe
(
'
/home/feature#usage
'
);
});
it
(
'
should set fragment when given fragment includes #
'
,
()
=>
{
const
url
=
urlUtils
.
setUrlFragment
(
'
/home/feature#overview
'
,
'
#install
'
);
expect
(
url
).
toBe
(
'
/home/feature#install
'
);
});
});
...
...
spec/javascripts/oauth_remember_me_spec.js
View file @
2cbc475e
...
...
@@ -22,7 +22,7 @@ describe('OAuthRememberMe', () => {
);
expect
(
$
(
'
#oauth-container .oauth-login.facebook
'
).
attr
(
'
href
'
)).
toBe
(
'
http://example.com/?redirect_fragment=L1&remember_me=1
'
'
http://example.com/?redirect_fragment=L1&remember_me=1
'
,
);
});
...
...
@@ -32,6 +32,8 @@ describe('OAuthRememberMe', () => {
expect
(
$
(
'
#oauth-container .oauth-login.twitter
'
).
attr
(
'
href
'
)).
toBe
(
'
http://example.com/
'
);
expect
(
$
(
'
#oauth-container .oauth-login.github
'
).
attr
(
'
href
'
)).
toBe
(
'
http://example.com/
'
);
expect
(
$
(
'
#oauth-container .oauth-login.facebook
'
).
attr
(
'
href
'
)).
toBe
(
'
http://example.com/?redirect_fragment=L1
'
);
expect
(
$
(
'
#oauth-container .oauth-login.facebook
'
).
attr
(
'
href
'
)).
toBe
(
'
http://example.com/?redirect_fragment=L1
'
,
);
});
});
spec/javascripts/pages/sessions/new/preserve_url_fragment_spec.js
View file @
2cbc475e
...
...
@@ -19,8 +19,16 @@ describe('preserve_url_fragment', () => {
it
(
'
adds the "redirect_fragment" query parameter to all OAuth and SAML login buttons
'
,
()
=>
{
preserveUrlFragment
(
'
#L65
'
);
expect
(
$
(
'
.omniauth-container #oauth-login-auth0
'
).
attr
(
'
href
'
)).
toBe
(
'
/users/auth/auth0?redirect_fragment=L65
'
);
expect
(
$
(
'
.omniauth-container #oauth-login-facebook
'
).
attr
(
'
href
'
)).
toBe
(
'
/users/auth/facebook?remember_me=1&redirect_fragment=L65
'
);
expect
(
$
(
'
.omniauth-container #oauth-login-saml
'
).
attr
(
'
href
'
)).
toBe
(
'
/users/auth/saml?redirect_fragment=L65
'
);
expect
(
$
(
'
.omniauth-container #oauth-login-auth0
'
).
attr
(
'
href
'
)).
toBe
(
'
/users/auth/auth0?redirect_fragment=L65
'
,
);
expect
(
$
(
'
.omniauth-container #oauth-login-facebook
'
).
attr
(
'
href
'
)).
toBe
(
'
/users/auth/facebook?remember_me=1&redirect_fragment=L65
'
,
);
expect
(
$
(
'
.omniauth-container #oauth-login-saml
'
).
attr
(
'
href
'
)).
toBe
(
'
/users/auth/saml?redirect_fragment=L65
'
,
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment