feat: Persist query params - #54
Conversation
f9770ed to
0793658
Compare
These fields were removed from IGeneVariant and IIndexMap, but the fixtures still passed them, so pnpm run check failed with three errors. Vitest strips types, so the tests kept passing and hid the breakage.
Iterator.prototype.map and toArray need Chrome 122, Firefox 131, or Safari 18.4, and nothing in the build polyfills them. Below those versions the call threw on every visit to the page, even with no query string, which the catch turned into an alert about parsing a file that the visitor had not selected.
The mps data comes from JSON.parse, so the in operator also matched inherited keys. A link such as ?toString=A1 reached Object.prototype and threw, which discarded every variant in the URL and left the visitor with an alert and an empty table.
parseVCFData left flipStrand at its default, so a reverse-strand variant read from a VCF was never normalized. The query params written from that variant are re-read through IndexMap.parser, which does set the flag, so the same genome gave one answer on upload and another after a reload. For rs1801133 that is the difference between NO ATTN and ATTN:CT. parseVCFData is no longer private so the round trip can be tested without going through a 100 MB file.
The Genotype column read the raw genotype while Attention and Interesting stayed in SNPedia orientation, so a reverse-strand row showed a flagged allele that did not appear in the genotype next to it, for example Genotype AG against ATTN:CT.
|
Reviewed and pushed five fixes to the branch.
The read-back is skipped. #43 specifies Query string vs fragment. Everything else here stays on the device, but a query string is sent to the server on any reload or shared link, so the genotypes end up in GitHub's request logs. A fragment ( The notice ("no data is sent or stored elsewhere") only stays accurate with the fragment. It also needs a line saying results are in the address, since anyone with the link can read them and it sits in browser history. |
|
I'm so glad you're around to clean up my mess 😅 Thanks for the additional commits!
Yeah, I decided to skip the read-back because it would cause a flicker as it reloaded the page. At the moment, the shortcut is the best compromise I can think of. Persistence to the address bar is a side-effect of parsing a file, and the address bar is used to load state if there happens to be state in the query params.
I hadn't thought of this! The data isn't personally identifiable though, so the most that github can get is an odd census (with lots of repeated data) about the SNPs we're concerned about. I'll add additional explanation to the preamble. |
|
@d6e Updated the preamble. Not sure how to make this any less wordy without compromising meaningful nuance. |
A query string is sent to the server on every reload and every visit to a shared link, putting the genotypes in request logs. A fragment is never put on the wire. URLSearchParams parses the fragment body unchanged, so the round trip is otherwise identical. This also restores the original notice, which 2e55643 had expanded only to explain those request logs.
|
After thinking about this more, I actually think we should just go with using a fragment ( |
Requires #52 to be merged