Skip to content

Commit 4f08f36

Browse files
authored
Encode parentheses in URL, Closes #110
1 parent c5a0330 commit 4f08f36

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/ldf-client-url-state.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,30 +73,37 @@ jQuery(function ($) {
7373
});
7474
// Set query string options
7575
if (datasources.persistent.length !== 0)
76-
queryString.push('datasources=' + datasources.persistent.map(encodeURIComponent).join(';'));
76+
queryString.push('datasources=' + datasources.persistent.map(encodeURIComponentExtended).join(';'));
7777
if (datasources.transient.length !== 0)
78-
queryString.push('transientDatasources=' + datasources.transient.map(encodeURIComponent).join(';'));
78+
queryString.push('transientDatasources=' + datasources.transient.map(encodeURIComponentExtended).join(';'));
7979
if (!hasDefaultQuery)
80-
queryString.push('query=' + encodeURIComponent(options.query || ''));
80+
queryString.push('query=' + encodeURIComponentExtended(options.query || ''));
8181
if (!hasDefaultQuery && options.queryContext)
82-
queryString.push('queryContext=' + encodeURIComponent(options.queryContext || ''));
82+
queryString.push('queryContext=' + encodeURIComponentExtended(options.queryContext || ''));
8383
if (!hasDefaultQuery && options.queryFormat !== 'sparql')
84-
queryString.push('resultsToTree=' + encodeURIComponent(options.resultsToTree));
84+
queryString.push('resultsToTree=' + encodeURIComponentExtended(options.resultsToTree));
8585
if (options.queryFormat !== 'sparql')
86-
queryString.push('queryFormat=' + encodeURIComponent(options.queryFormat || ''));
86+
queryString.push('queryFormat=' + encodeURIComponentExtended(options.queryFormat || ''));
8787
if (options.datetime)
88-
queryString.push('datetime=' + encodeURIComponent(options.datetime));
88+
queryString.push('datetime=' + encodeURIComponentExtended(options.datetime));
8989
if (options.httpProxy)
90-
queryString.push('httpProxy=' + encodeURIComponent(options.httpProxy));
90+
queryString.push('httpProxy=' + encodeURIComponentExtended(options.httpProxy));
9191
if (options.bypassCache)
92-
queryString.push('bypassCache=' + encodeURIComponent(options.bypassCache));
92+
queryString.push('bypassCache=' + encodeURIComponentExtended(options.bypassCache));
9393
if (options.executeOnLoad)
94-
queryString.push('executeOnLoad=' + encodeURIComponent(options.executeOnLoad));
94+
queryString.push('executeOnLoad=' + encodeURIComponentExtended(options.executeOnLoad));
9595
if (options.solidIdp && options.solidAuth.defaultIdp !== options.solidIdp)
96-
queryString.push('solidIdp=' + encodeURIComponent(options.solidIdp));
96+
queryString.push('solidIdp=' + encodeURIComponentExtended(options.solidIdp));
9797

9898
// Compose new URL with query string
9999
queryString = queryString.length ? '#' + queryString.join('&') : '';
100100
history.replaceState(null, null, location.href.replace(/(?:#.*)?$/, queryString));
101101
}
102102
});
103+
104+
// encodeURIComponent function extended with encoding for parenthesis
105+
function encodeURIComponentExtended(component) {
106+
return encodeURIComponent(component)
107+
.replace(/\(/g, '%28')
108+
.replace(/\)/g, '%29');
109+
}

0 commit comments

Comments
 (0)