gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit8342cd288342cd28Merge branch 'notes9-no-poll' into mainAtlas8342cd28/lib/api-helpers.hl

1.2 KB

  1. // lib/api-helpers.hl — what lib/api.hl looks up (notes mission 002, code order): the JSON answer, the field type
  2. // checks and the login button's `?next=` check.
  3. import { Response } from 'hl:http1'
  4. static apiHeaders = { 'Content-Type' = 'application/json; charset=utf-8' 'Cache-Control' = 'no-store' 'X-Content-Type-Options' = 'nosniff' }
  5. static reply = (Number status, Hybrid value) => { return new Response(JSON.stringify(value), { status = status headers = apiHeaders }) }
  6. static isText = (v) => { return v != null && hlTypeName(v) == 'String' }
  7. static isTime = (v) => { return v != null && hlTypeName(v) == 'Number' && v >= 0 }
  8. // BACK TO THE PAGE: /login.js puts `?next=` into the button's return URL at the click. Only a same-origin PATH
  9. // goes (one `/`, URL-safe characters, ≤ 500). Anything else → `/`.
  10. static nextChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~/?&=%+,;@!$()*:'
  11. static safePath = (want) => {
  12. if (want == null || hlTypeName(want) != 'String' || want == '' || want.length > 500) { return '/' }
  13. if (want.slice(0, 1) != '/' || want.slice(0, 2) == '//' || want.slice(0, 7) == '/login/') { return '/' }
  14. let i = 0
  15. while (i < want.length) {
  16. if (!nextChars.includes(want[i])) { return '/' }
  17. i = i + 1
  18. }
  19. return want
  20. }

Branches

Latest commits

  • 8342cd28Merge branch 'notes9-no-poll' into mainAtlas
  • 1f0457a5|||PR make provisional rejected-draft setup deterministicAtlas
  • 996768bf|||PR WIP sequence note creation before provisional-id adoptionAtlas
  • c49ce093|||PR WIP remove notes polling and use framework reachabilityAtlas
  • c028ac61Merge branch 'notes-pr7-kunibert' into mainAtlas
  • 9cc92bdfKeep conflict and history fixes while awaiting queued save supportAtlas
  • a5c27cb6Allow real edits back to earlier text and honor configured identAtlas
  • 15c46ced|||PR Preserve note edits, conflict bases and visible historyAtlas
  • 4c6e0bf6Merge branch 'notes13-day61' into mainAtlas
  • eb51864f|||PR Back/Forward via navigate, server drafts, Hybriel day61Atlas
  • 3537cf7eMerge branch 'vendor-day59' into mainAtlas
  • c13d188b|||PR Vendor Hybriel day59Atlas
  • 24c95433Merge branch 'notes17-ghost-note' into mainAtlas
  • ae1075b2Preserve rejected drafts during note ID adoptionAtlas
  • 383cce23|||PR Prevent saved local edits from restoring deleted notesAtlas
  • 99ca1cf6Merge branch 'vendor-day56' into mainAtlas
  • 649cef37|||PR Vendor Hybriel day56Atlas
  • aadd0abcMerge branch 'hl-standard-2' into mainAtlas
  • 52ffac9f|||PR Keyboard and reload checks for the notes gate (HL-STANDARD F21, F5)Atlas
  • 617ee8c0Merge branch 'hl-standard' into mainAtlas