Skip to content

Commit 4b9c98c

Browse files
authored
Corrected the link created from a custom query's SHARE QUERY button for the case where the base URL includes a path (#170)
1 parent cf0d451 commit 4b9c98c

File tree

10 files changed

+12
-14
lines changed

10 files changed

+12
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Templated queries now also work for queries containing multiple occurrences of a template variable (#164).
1313
- Works when served from any base URL including a path (e.g. `https://www.example.com/your/preferred/path`) (#165).
14+
- Corrected the link created from a custom query's SHARE QUERY button for the case where the base URL includes a path (#169).
1415

1516
## [1.4.0] - 2024-10-02
1617

main/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lint:markdown": "markdownlint-cli2",
1212
"lint:markdown:fix": "markdownlint-cli2-fix",
1313
"preview": "vite preview",
14-
"dev-with-path": "vite --base /random/path"
14+
"dev-with-path": "vite --base /random/path/"
1515
},
1616
"dependencies": {
1717
"@comunica/query-sparql": "^3.2.3",

main/src/components/CustomQueryEditor/customQueryEditButton.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ export default function CustomQueryEditButton({ queryID, submitted = false }) {
3636

3737
const handleSave = () => {
3838

39-
const url = new URL(window.location.href);
40-
const serverURL = `${url.protocol}//${url.hostname}${url.port ? ':' + url.port : ''}`;
41-
42-
const savedUrl = `${serverURL}/#/customQuery?${customQuery.searchParams.toString()}`;
39+
const savedUrl = `${window.location.href.split('/#/')[0]}/#/customQuery?${customQuery.searchParams.toString()}`;
4340
setCopyUrl(savedUrl);
4441
}
4542

test/cypress.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default defineConfig({
55
experimentalStudio: true,
66
experimentalRunAllSpecs: true,
77
defaultCommandTimeout: 10000, /* is OK for very slow computers */
8-
baseUrl: 'http://localhost:5173/random/path',
8+
baseUrl: 'http://localhost:5173/random/path/', /* include trailing slash */
99
video: false
1010
},
1111
});

test/cypress/e2e/custom-query-editor.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ SELECT * WHERE {
138138

139139
})
140140

141-
it("Saves the correct URL", () => {
141+
it("Shares the correct URL", () => {
142142

143143
cy.visit("/#/customQuery");
144144

@@ -163,7 +163,7 @@ SELECT * WHERE {
163163
cy.get('button').contains("Share Query").click();
164164

165165
cy.get('textarea[name="queryURL"]').invoke('val').then((val) => {
166-
expect(val).to.include('?name=new+query&description=new+description&queryString=PREFIX+schema%3A+%3Chttp%3A%2F%2Fschema.org%2F%3E+%0ASELECT+*+WHERE+%7B%0A++++%3Flist+schema%3Aname+%3FlistTitle%3B%0A++++++schema%3AitemListElement+%5B%0A++++++schema%3Aname+%3FbookTitle%3B%0A++++++schema%3Acreator+%5B%0A++++++++schema%3Aname+%3FauthorName%0A++++++%5D%0A++++%5D.%0A%7D&source=http%3A%2F%2Flocalhost%3A8080%2Fexample%2Fwish-list');
166+
expect(val).to.equal(Cypress.config('baseUrl') + '#/customQuery?name=new+query&description=new+description&queryString=PREFIX+schema%3A+%3Chttp%3A%2F%2Fschema.org%2F%3E+%0ASELECT+*+WHERE+%7B%0A++++%3Flist+schema%3Aname+%3FlistTitle%3B%0A++++++schema%3AitemListElement+%5B%0A++++++schema%3Aname+%3FbookTitle%3B%0A++++++schema%3Acreator+%5B%0A++++++++schema%3Aname+%3FauthorName%0A++++++%5D%0A++++%5D.%0A%7D&source=http%3A%2F%2Flocalhost%3A8080%2Fexample%2Fwish-list');
167167
});
168168

169169

test/cypress/e2e/fetch-status.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe("Fetch Status", () => {
4949
cy.contains("button", "Authorize").click();
5050
});
5151

52-
cy.url().should("eq", Cypress.config('baseUrl') + "/");
52+
cy.url().should("eq", Cypress.config('baseUrl'));
5353

5454
// Go to the mixed book query
5555
cy.contains("For testing only").click();

test/cypress/e2e/log-in.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe("Log in", () => {
4848
cy.contains("button", "Authorize").click();
4949
});
5050

51-
cy.url().should("eq", Cypress.config('baseUrl') + "/");
51+
cy.url().should("eq", Cypress.config('baseUrl'));
5252
});
5353

5454
it("Log in with an invalid IDP issuer", () => {
@@ -83,7 +83,7 @@ describe("Log in", () => {
8383
cy.contains("button", "Authorize").click();
8484
});
8585

86-
cy.url().should("eq", Cypress.config('baseUrl') + "/");
86+
cy.url().should("eq", Cypress.config('baseUrl'));
8787

8888
cy.contains("General examples").click();
8989
cy.contains("A secret list of my favorite books").click();

test/cypress/e2e/save-custom-queries-on-pod.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe("Saving custom queries on pods - logged in", () => {
3131
cy.contains("button", "Authorize").click();
3232
});
3333

34-
cy.url().should("eq", Cypress.config('baseUrl') + "/");
34+
cy.url().should("eq", Cypress.config('baseUrl'));
3535

3636
cy.visit("/#");
3737
});

test/cypress/e2e/sources-from-indexfile.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe("Sources from index file", () => {
9595
cy.contains("button", "Authorize").click();
9696
});
9797

98-
cy.url().should("eq", Cypress.config('baseUrl') + "/");
98+
cy.url().should("eq", Cypress.config('baseUrl'));
9999

100100
//now try again
101101
cy.contains("For testing only").click();

test/cypress/e2e/sources-info.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe("Sources info", () => {
6363
cy.contains("button", "Authorize").click();
6464
});
6565

66-
cy.url().should("eq", Cypress.config('baseUrl') + "/");
66+
cy.url().should("eq", Cypress.config('baseUrl'));
6767

6868
cy.contains("General examples").click();
6969
cy.contains("A secret list of my favorite books").click();

0 commit comments

Comments
 (0)