mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 22:44:24 +01:00
Change challenge location has to include and work off of challenge ID (#1522)
* Adds challenge ID into location hashes so that the right challenge is always loaded regardless of duplicate names * Closes #1120
This commit is contained in:
@@ -34,8 +34,11 @@ const loadChal = id => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loadChalByName = name => {
|
const loadChalByName = name => {
|
||||||
const chal = $.grep(challenges, chal => chal.name == name)[0];
|
let idx = name.lastIndexOf("-");
|
||||||
|
let pieces = [name.slice(0, idx), name.slice(idx + 1)];
|
||||||
|
let id = pieces[1];
|
||||||
|
|
||||||
|
const chal = $.grep(challenges, chal => chal.id == id)[0];
|
||||||
displayChal(chal);
|
displayChal(chal);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -118,7 +121,7 @@ const displayChal = chal => {
|
|||||||
challenge.postRender();
|
challenge.postRender();
|
||||||
|
|
||||||
window.location.replace(
|
window.location.replace(
|
||||||
window.location.href.split("#")[0] + "#" + chal.name
|
window.location.href.split("#")[0] + `#${chal.name}-${chal.id}`
|
||||||
);
|
);
|
||||||
$("#challenge-window").modal();
|
$("#challenge-window").modal();
|
||||||
});
|
});
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -257,7 +257,9 @@
|
|||||||
{% for solve in solves %}
|
{% for solve in solves %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}">{{ solve.challenge.name }}</a>
|
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}-{{ solve.challenge.id }}">
|
||||||
|
{{ solve.challenge.name }}
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="d-none d-md-block d-lg-block">{{ solve.challenge.category }}</td>
|
<td class="d-none d-md-block d-lg-block">{{ solve.challenge.category }}</td>
|
||||||
<td>{{ solve.challenge.value }}</td>
|
<td>{{ solve.challenge.value }}</td>
|
||||||
|
|||||||
@@ -154,7 +154,9 @@
|
|||||||
{% for solve in solves %}
|
{% for solve in solves %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}">{{ solve.challenge.name }}</a>
|
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}-{{ solve.challenge.id }}">
|
||||||
|
{{ solve.challenge.name }}
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="d-none d-md-block d-lg-block">{{ solve.challenge.category }}</td>
|
<td class="d-none d-md-block d-lg-block">{{ solve.challenge.category }}</td>
|
||||||
<td>{{ solve.challenge.value }}</td>
|
<td>{{ solve.challenge.value }}</td>
|
||||||
|
|||||||
@@ -121,7 +121,9 @@
|
|||||||
{% for solve in user.solves %}
|
{% for solve in user.solves %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}">{{ solve.challenge.name }}</a>
|
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}-{{ solve.challenge.id }}">
|
||||||
|
{{ solve.challenge.name }}
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="d-none d-md-block d-lg-block">{{ solve.challenge.category }}</td>
|
<td class="d-none d-md-block d-lg-block">{{ solve.challenge.category }}</td>
|
||||||
<td>{{ solve.challenge.value }}</td>
|
<td>{{ solve.challenge.value }}</td>
|
||||||
|
|||||||
@@ -121,7 +121,9 @@
|
|||||||
{% for solve in user.solves %}
|
{% for solve in user.solves %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}">{{ solve.challenge.name }}</a>
|
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}-{{ solve.challenge.id }}">
|
||||||
|
{{ solve.challenge.name }}
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="d-none d-md-block d-lg-block">{{ solve.challenge.category }}</td>
|
<td class="d-none d-md-block d-lg-block">{{ solve.challenge.category }}</td>
|
||||||
<td>{{ solve.challenge.value }}</td>
|
<td>{{ solve.challenge.value }}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user