Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
a97f45d0
Commit
a97f45d0
authored
2 years ago
by
Elmar Ludwig
Browse files
Options
Downloads
Patches
Plain Diff
completely replace JS URLHelper implementation, fixes #1395
Closes #1395 Merge request
studip/studip!852
parent
d547a2c2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
resources/assets/javascripts/lib/url_helper.js
+18
-43
18 additions, 43 deletions
resources/assets/javascripts/lib/url_helper.js
templates/start/_jstemplates.php
+1
-1
1 addition, 1 deletion
templates/start/_jstemplates.php
with
19 additions
and
44 deletions
resources/assets/javascripts/lib/url_helper.js
+
18
−
43
View file @
a97f45d0
...
...
@@ -21,22 +21,6 @@ class URLHelper {
this
.
parameters
=
parameters
;
}
/**
* method to extend short URLs like "dispatch.php/profile" to "http://.../dispatch.php/profile"
*/
resolveURL
(
url
)
{
if
(
!
_
.
isString
(
this
.
base_url
)
||
url
.
match
(
/^
[
a-zA-Z
][
a-zA-Z0-9+-.
]
*:/
)
!==
null
||
url
.
charAt
(
0
)
===
'
?
'
)
{
//this method cannot do any more:
return
url
;
}
var
base_url
=
this
.
base_url
;
if
(
url
.
charAt
(
0
)
===
'
/
'
)
{
var
host
=
this
.
base_url
.
match
(
/^
[
a-zA-Z
][
a-zA-Z0-9+-.
]
*:
\/\/[\w
:.-
]
+/
);
base_url
=
host
?
host
[
0
]
:
''
;
}
return
base_url
+
url
;
}
/**
* returns a readily encoded URL with the mandatory parameters and additionally passed
* parameters.
...
...
@@ -47,40 +31,31 @@ class URLHelper {
* @return: url with all necessary and additional parameters, encoded
*/
getURL
(
url
,
param_object
,
ignore_params
)
{
var
params
=
_
.
defaults
(
param_object
||
{},
ignore_params
?
{}
:
this
.
parameters
),
tmp
,
fragment
,
query
;
let
result
;
tmp
=
url
.
split
(
'
#
'
);
url
=
tmp
[
0
];
fragment
=
tmp
[
1
];
tmp
=
url
.
split
(
'
?
'
);
url
=
tmp
[
0
];
query
=
tmp
[
1
]
||
''
;
if
(
url
!==
''
)
{
url
=
this
.
resolveURL
(
url
);
if
(
url
===
''
||
url
.
match
(
/^
[
?#
]
/
))
{
result
=
new
URL
(
url
,
location
.
href
.
replace
(
/
\?
.*/
,
''
));
}
else
{
result
=
new
URL
(
url
,
this
.
base_url
);
}
query
=
decodeURIComponent
(
query
);
// split query string and merge with param_object
_
.
each
((
query
&&
query
.
split
(
'
&
'
))
||
[],
function
(
e
)
{
var
pair
=
e
.
split
(
'
=
'
);
if
(
!
(
pair
[
0
]
in
params
))
{
params
[
pair
[
0
]]
=
pair
[
1
];
}
});
if
(
_
.
keys
(
params
).
length
||
url
===
''
)
{
url
+=
'
?
'
+
jQuery
.
param
(
params
);
if
(
!
ignore_params
)
{
for
(
let
key
in
this
.
parameters
)
{
if
(
!
result
.
searchParams
.
has
(
key
))
{
result
.
searchParams
.
set
(
key
,
this
.
parameters
[
key
]);
}
}
}
if
(
fragment
)
{
url
+=
'
#
'
+
fragment
;
for
(
let
key
in
param_object
)
{
if
(
param_object
[
key
]
!==
null
)
{
result
.
searchParams
.
set
(
key
,
param_object
[
key
]);
}
else
{
result
.
searchParams
.
delete
(
key
);
}
}
return
url
;
return
result
.
href
;
}
}
...
...
This diff is collapsed.
Click to expand it.
templates/start/_jstemplates.php
+
1
−
1
View file @
a97f45d0
...
...
@@ -56,7 +56,7 @@
<
/span
>
<
div
class
=
"
activity-heading
"
>
<%
if
(
activity
.
actor
.
type
!==
'
anonymous
'
)
{
%>
<
a
href
=
"
<%- STUDIP.URLHelper.
resolve
URL('dispatch.php/profile?username=' + activity.actor.details.name.username) %>
"
>
<
a
href
=
"
<%- STUDIP.URLHelper.
get
URL('dispatch.php/profile?username=' + activity.actor.details.name.username) %>
"
>
<
img
src
=
"
<%- activity.actor.details.avatar_medium %>
"
class
=
"
activity-avatar
"
>
<
/a
>
<%
}
%>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment