Repository: vgteam/sequenceTubeMap (js)

Issue:
CopyLink: Use window.location.origin instead of window.location.host
CopyLink does not work if HTTPS is used for the the app. The protocol is missing.

I created a pull request #184

Pull request description:
Support protocol in copied links
This is on top of #184 and will fix #186.

Patch:
diff --git a/src/components/CopyLink.js b/src/components/CopyLink.js
index 72ce775..91be277 100644
--- a/src/components/CopyLink.js
+++ b/src/components/CopyLink.js
@@ -23,7 +23,7 @@ export function CopyLink(props) {
     const viewTarget = props.getCurrentViewTarget();
 
     const params = new URLSearchParams(viewTarget).toString();
-    const full = window.location.host + "?" + params;
+    const full = window.location.origin + "?" + params;
     copyCallback(full);
 
     // Write link to clipboard


Test patch:
diff --git a/src/end-to-end.test.js b/src/end-to-end.test.js
index 9c0ce7c..04bc96e 100644
--- a/src/end-to-end.test.js
+++ b/src/end-to-end.test.js
@@ -256,7 +256,7 @@ describe("When we wait for it to load", () => {
 it("produces correct link for view before & after go is pressed", async () => {
   // First test that after pressing go, the link reflects the dat form
   const expectedLinkBRCA1 =
-    "localhost?name=snp1kg-BRCA1&xgFile=snp1kg-BRCA1.vg.xg&gamFile=NA12878-BRCA1.sorted.gam&dataPath=default&region=17%3A1-100&bedFile=snp1kg-BRCA1.bed&dataType=built-in";
+    "http://localhost?name=snp1kg-BRCA1&xgFile=snp1kg-BRCA1.vg.xg&gamFile=NA12878-BRCA1.sorted.gam&dataPath=default&region=17%3A1-100&bedFile=snp1kg-BRCA1.bed&dataType=built-in";
   // Set up dropdown
   await act(async () => {
     let dropdown = document.getElementById("dataSourceSelect");
@@ -290,7 +290,7 @@ it("produces correct link for view before & after go is pressed", async () => {
   await clickCopyLink();
 
   const expectedLinkCactus =
-    "localhost?name=cactus&region=ref%3A1-100&xgFile=cactus.vg.xg&gamFile=cactus-NA12879.sorted.gam&bedFile=cactus.bed&dataPath=mounted&dataType=built-in";
+    "http://localhost?name=cactus&region=ref%3A1-100&xgFile=cactus.vg.xg&gamFile=cactus-NA12879.sorted.gam&bedFile=cactus.bed&dataPath=mounted&dataType=built-in";
   // Make sure link has changed after pressing go
   expect(fakeClipboard).toEqual(expectedLinkCactus);
 });