Skip to content

Commit

Permalink
fix: URLが文字数以上になったら切り詰める処理を追加 #196 (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiro4989 authored Nov 28, 2020
1 parent 485d879 commit 3cb8e9a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion websh_front/src/index.nim
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ proc deleteFileButtonOnClicked(i: int): proc(ev: Event, n: VNode) =
inputImages[i].name = cstring""
inputImages[i].data = cstring""

proc croppedUrl(): string =
## limit 以上の文字数になったURLを切り詰めて ... を付与する。
const limit = 80
result = &"{baseUrl}?code={encodeUrl($inputShell, false)}"
if limit < result.len:
result = result[0..<limit] & "..."

proc createDom(): VNode =
result = buildHtml(tdiv):

Expand Down Expand Up @@ -230,7 +237,7 @@ proc createDom(): VNode =
text $elem
tdiv:
a(href = &"{baseUrl}?code={encodeUrl($inputShell, false)}"):
text &"{baseUrl}?code={encodeUrl($inputShell, false)}"
text croppedUrl()
article(class = "tile is-child notification"):
p(class = "title"):
text "history"
Expand Down

0 comments on commit 3cb8e9a

Please sign in to comment.