-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add URL-safe Base64 Encoding/Decoding for Dynamic Sample Redirection #141
base: main
Are you sure you want to change the base?
Add URL-safe Base64 Encoding/Decoding for Dynamic Sample Redirection #141
Conversation
- Import UrlsafeCodec for encoding/decoding functionality. - Implement isWebAddress utility function to validate URLs. - Adjust useEffect to fetch data only from valid web addresses. - Add new useEffect to handle non-web address URLs with UrlsafeCodec.
- Add headerCheck parameter to encode method with default value false - Modify pako.deflate call to conditionally use raw option based on headerCheck - Update JSDoc comments to reflect new parameter and its functionality
Thank you @janvandenschilden for making the first outside contribution to this repo!! If I understand correctly, with this change, users can use the A few requests/questions:
|
This commit introduces the JsonBase64Converter component, which allows users to encode and decode JSON data using a URL-safe base64 encoding. The component provides a user-friendly interface for handling JSON-to-base64 conversions. Changes made: - Added JsonBase64Converter component. - Integrated the component into the App and main entry files. Usage: - Navigate to "/dev/codec" to access the JsonBase64Converter.
Hi @sehilyi Thank you for the warm welcome and for considering my pull request. I’m happy to be the first external contributor to this project, and I’m equally excited that this is my first contribution to an external repository. Regarding the implementation, the By providing the URL to a data configuration file. To facilitate the encoding process, I’ve developed a utility component and a dedicated page within the application at the As an example, I will give an example of json file and what it is encoded to. [
{
"group": "default",
"id": "9ae0744a-9bc1-4cd7-b7cf-c6569ed9e4aa",
"cancer": "kidney",
"assembly": "hg19",
"sv": "https://s3.amazonaws.com/gosling-lang.org/data/SV/9ae0744a-9bc1-4cd7-b7cf-c6569ed9e4aa.pcawg_consensus_1.6.161022.somatic.sv.bedpe",
"cnv": "https://s3.amazonaws.com/gosling-lang.org/data/SV/9ae0744a-9bc1-4cd7-b7cf-c6569ed9e4aa.consensus.20170119.somatic.cna.annotated.txt",
"vcf": "https://somatic-browser-test.s3.amazonaws.com/browserExamples/9ae0744a-9bc1-4cd7-b7cf-c6569ed9e4aa.consensus.20160830.somatic.snv_mnv.sorted.vcf.gz",
"vcfIndex":"https://somatic-browser-test.s3.amazonaws.com/browserExamples/9ae0744a-9bc1-4cd7-b7cf-c6569ed9e4aa.consensus.20160830.somatic.snv_mnv.sorted.vcf.gz.tbi",
"vcf2": "https://somatic-browser-test.s3.amazonaws.com/browserExamples/9ae0744a-9bc1-4cd7-b7cf-c6569ed9e4aa.consensus.20161006.somatic.indel.sorted.vcf.gz",
"vcf2Index":"https://somatic-browser-test.s3.amazonaws.com/browserExamples/9ae0744a-9bc1-4cd7-b7cf-c6569ed9e4aa.consensus.20161006.somatic.indel.sorted.vcf.gz.tbi",
"thumbnail": "_9ae0744a"
},
{
"group": "default",
"id": "b27d75ba-5989-4200-bfe9-f1b7d7cf8008",
"cancer": "breast",
"assembly": "hg19",
"sv": "https://s3.amazonaws.com/gosling-lang.org/data/SV/b27d75ba-5989-4200-bfe9-f1b7d7cf8008.pcawg_consensus_1.6.161022.somatic.sv.bedpe",
"cnv": "https://s3.amazonaws.com/gosling-lang.org/data/SV/b27d75ba-5989-4200-bfe9-f1b7d7cf8008.consensus.20170119.somatic.cna.annotated.txt",
"vcf": "https://somatic-browser-test.s3.amazonaws.com/browserExamples/b27d75ba-5989-4200-bfe9-f1b7d7cf8008.consensus.20160830.somatic.snv_mnv.sorted.vcf.gz",
"vcfIndex":"https://somatic-browser-test.s3.amazonaws.com/browserExamples/b27d75ba-5989-4200-bfe9-f1b7d7cf8008.consensus.20160830.somatic.snv_mnv.sorted.vcf.gz.tbi",
"vcf2": "https://somatic-browser-test.s3.amazonaws.com/browserExamples/b27d75ba-5989-4200-bfe9-f1b7d7cf8008.consensus.20161006.somatic.indel.sorted.vcf.gz",
"vcf2Index":"https://somatic-browser-test.s3.amazonaws.com/browserExamples/b27d75ba-5989-4200-bfe9-f1b7d7cf8008.consensus.20161006.somatic.indel.sorted.vcf.gz.tbi",
"thumbnail": "_b27d75ba"
},
{
"group": "default",
"id": "fc8edf46-2005-1af4-e040-11ac0d481414",
"cancer": "breast",
"assembly": "hg19",
"sv": "https://s3.amazonaws.com/gosling-lang.org/data/SV/fc8edf46-2005-1af4-e040-11ac0d481414.pcawg_consensus_1.6.161022.somatic.sv.bedpe",
"cnv": "https://s3.amazonaws.com/gosling-lang.org/data/SV/fc8edf46-2005-1af4-e040-11ac0d481414.consensus.20170119.somatic.cna.annotated.txt",
"vcf": "https://somatic-browser-test.s3.amazonaws.com/browserExamples/fc8edf46-2005-1af4-e040-11ac0d481414.consensus.20160830.somatic.snv_mnv.sorted.vcf.gz",
"vcfIndex":"https://somatic-browser-test.s3.amazonaws.com/browserExamples/fc8edf46-2005-1af4-e040-11ac0d481414.consensus.20160830.somatic.snv_mnv.sorted.vcf.gz.tbi",
"vcf2": "https://somatic-browser-test.s3.amazonaws.com/browserExamples/fc8edf46-2005-1af4-e040-11ac0d481414.consensus.20161006.somatic.indel.sorted.vcf.gz",
"vcf2Index":"https://somatic-browser-test.s3.amazonaws.com/browserExamples/fc8edf46-2005-1af4-e040-11ac0d481414.consensus.20161006.somatic.indel.sorted.vcf.gz.tbi",
"thumbnail": "_fc8edf46"
}
]
|
adce8a4
to
7675e5d
Compare
base: '/app/', | ||
base: '/', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized this change makes the demo of the chromoscope inaccessible via chromoscope.bio/app
. I tested this by running the following commands.
# build both the documentation and demo and create a "\build" folder to organize files
yarn predeploy
# enables browsing the built project (i.e., doc and demo) by running a local server
http-server ./build
How the document and demo are organized under \build
:
build
- index.html // ← documentation (i.e., "chromoscope.bio")
- ...
- app
- index.html // ← demo (i.e., "chromoscope.bio/app")
- ...
By setting base: '/app/'
, the index.html
file for the demo (i.e., app/index.html
) created by vite
has proper relative paths (e.g., app/index.js
instead of index.js
). So, without setting the base
option, chromoscope.bio/app
(app/index.html
) ends up having the wrong relative paths, making the demo not work.
I did not find a simple way to walk around this and would need to experiment more for a better alternative, but we can simply create an inlined HTML file for the webpage that you created (instead of using React) and put that under a /dev/codec/
folder.
build
- index.html // ← documentation (i.e., "chromoscope.bio")
- ...
- app
- index.html // ← demo (i.e., "chromoscope.bio/app")
- ...
- dev
- codec
- index.html // ← simple page to convert JSON to str
In this way, users should be able to access the webpage via "chromoscope.bio/dev/codec/'.
What changes are being proposed?
This pull request introduces a new feature that allows JSON data to be encoded into a URL using base64 encoding. This enhancement enables dynamic redirection of users to specific samples without the need to create a separate JSON file for each possibility. The implementation includes a new utility class,
UrlsafeCodec
, which handles the encoding and decoding process, ensuring that the data is URL-safe.Why are these changes necessary?
The changes address issue #133, which highlighted the need for a more efficient way to handle sample redirection. By encoding the JSON data directly into the URL, we can significantly simplify the process for users and maintainers alike, making the application more flexible and user-friendly.
How have these changes been tested?
The new encoding and decoding functionality has been thoroughly tested with various JSON data structures to ensure reliability and stability. Manual testing has been conducted to confirm that the feature works as expected in the application.