Skip to content

Commit

Permalink
hopefully more consistency in encodeURIComponent usage
Browse files Browse the repository at this point in the history
  • Loading branch information
sdumetz committed Dec 11, 2024
1 parent a987490 commit 53190c1
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion source/ui/composants/HistoryAggregation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class HistoryEntryAggregate extends i18n(LitElement){
this.#c.abort();
this.#c = new AbortController();
console.log("Fetch entry : ", this.scene, this.entries[0]);
fetch(`/history/${encodeURIComponent(this.scene)}/${this.entries[0].id.toString()}/diff`, {
fetch(`/history/${this.scene}/${this.entries[0].id.toString()}/diff`, {
signal: this.#c.signal,
headers: {"Accept": "application/json"},
}).then(async (r)=>{
Expand Down
4 changes: 2 additions & 2 deletions source/ui/composants/SceneCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ import { AccessType, AccessTypes, Scene } from "../state/withScenes";
}

protected render() :TemplateResult {
let explorer = `/ui/scenes/${encodeURIComponent(this.name)}/view`;
let story = `/ui/scenes/${encodeURIComponent(this.name)}/edit`;
let explorer = `/ui/scenes/${this.name}/view`;
let story = `/ui/scenes/${this.name}/edit`;
return html`
<div class="scene-card-inner ${this.cardStyle == "list" ? "scene-card-inner-list": ""}">
<div style="display:flex; flex:auto; align-items:center;">
Expand Down
7 changes: 6 additions & 1 deletion source/ui/composants/TagList.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LitElement, css, customElement, html, property } from "lit-element";
import { navigate } from "../state/router";



Expand Down Expand Up @@ -27,13 +28,17 @@ export default class TagList extends LitElement{


private onRemove = (e:Event)=>{
e.preventDefault();
e.stopPropagation();
this.dispatchEvent(new CustomEvent("remove", {detail:(e.target as HTMLButtonElement).name}));
}

private onClick = (index :number, ev :Event)=>{
ev.preventDefault();
ev.stopPropagation();
this.dispatchEvent(new CustomEvent("click", {detail: {name: this.tags[index], index}}));
if(this.dispatchEvent(new CustomEvent("click", {detail: {name: this.tags[index], index}}))){
navigate(this, `/ui/tags/${this.tags[index]}`);
}
}

render(){
Expand Down
2 changes: 1 addition & 1 deletion source/ui/composants/UserLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import Notification from "./Notification";
ev.preventDefault();
const username = ev.target["username"].value;
this.active = true;
fetch(`/auth/login/${username}/link`, {
fetch(`/auth/login/${encodeURIComponent(username)}/link`, {
method: "POST",
}).then(async (r)=>{
if(!r.ok){
Expand Down
2 changes: 1 addition & 1 deletion source/ui/screens/Admin/AdminArchives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface User {

onDeleteScene = (ev :MouseEvent, s :Scene)=>{
ev.preventDefault();
fetch(`/scenes/${s.name}?archive=false`, {
fetch(`/scenes/${encodeURIComponent(s.name)}?archive=false`, {
headers: {"Content-Type": "application/json"},
method: "DELETE"
}).then(HttpError.okOrThrow)
Expand Down
2 changes: 1 addition & 1 deletion source/ui/screens/Admin/UsersList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ interface User {
</div>`;
}
createLoginLink(u :User){
fetch(`/auth/login/${u.username}/link`, {
fetch(`/auth/login/${encodeURIComponent(u.username)}/link`, {
method: "GET",
headers: {
"Content-Type": "text/plain"
Expand Down
6 changes: 3 additions & 3 deletions source/ui/screens/SceneHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ interface AccessRights{
</div>`;
}

let scene = encodeURIComponent(this.name);
let scene = this.name;
return html`<div>
<h1 style="color:white">${this.name}</h1>
Expand All @@ -142,7 +142,7 @@ interface AccessRights{
<ui-icon name="edit"></ui-icon> ${this.t("ui.editScene")}
</a>`:null}
<a class="btn btn-main" style="margin-top:10px" href=${`/ui/scenes/${scene}/view`}><ui-icon name="eye"></ui-icon> ${this.t("ui.viewScene")}</a>
<a class="btn btn-main" style="margin-top:10px" download href="/scenes/${scene}?format=zip"><ui-icon name="save"></ui-icon> ${this.t("ui.downloadScene")}</a>
<a class="btn btn-main" style="margin-top:10px" download="${scene}.zip" href="/scenes/${scene}?format=zip"><ui-icon name="save"></ui-icon> ${this.t("ui.downloadScene")}</a>
</div>
</div>
Expand Down Expand Up @@ -358,7 +358,7 @@ interface AccessRights{
}).then((r)=>{
if(r.ok){
Notification.show("Renamed "+this.name+" to "+name, "info", 1600);
navigate(this, `/ui/scenes/${encodeURIComponent(name)}/`);
navigate(this, `/ui/scenes/${name}/`);
}else{
throw new Error(`[${r.status}] ${r.statusText}`);
}
Expand Down
4 changes: 2 additions & 2 deletions source/ui/screens/Tags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ export default class TagsScreen extends router(withUser(LitElement)){


handleTagClick = (e:CustomEvent<{name:string, index:number}>)=>{
navigate(this, `${this.path}${encodeURIComponent(this.tags[e.detail.index].name)}`);
navigate(this, `${this.path}${this.tags[e.detail.index].name}`);
}

formatTag({name, size}:Tag){
return `${name} (${size})`;
}

render(){
const selection = this.tags.findIndex((t)=>this.isActive(`${encodeURIComponent(t.name)}`))
const selection = this.tags.findIndex((t)=>this.isActive(`${t.name}`))
return html`
<h2>Tags</h2>
<div class="section">
Expand Down

0 comments on commit 53190c1

Please sign in to comment.