From a6280dcc75903490f1e4b730d459aad36796630a Mon Sep 17 00:00:00 2001 From: Evan Shortiss Date: Tue, 9 Aug 2022 12:28:57 -0700 Subject: [PATCH] allow hypen prefix in substitutions --- preview-src/index-username.adoc | 1 + preview-src/index.adoc | 4 ++++ src/js/07-userparams-behaviour.js | 10 ++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 preview-src/index-username.adoc diff --git a/preview-src/index-username.adoc b/preview-src/index-username.adoc new file mode 100644 index 0000000..35d746b --- /dev/null +++ b/preview-src/index-username.adoc @@ -0,0 +1 @@ +This is an empty page used to help verify the parameter replacement in content containing leading hyphens, i.e `%NAME%` should be replaced in both `hello-%NAME%` and `hello %NAME%`. \ No newline at end of file diff --git a/preview-src/index.adoc b/preview-src/index.adoc index 3f1d5a8..ecceca2 100644 --- a/preview-src/index.adoc +++ b/preview-src/index.adoc @@ -32,6 +32,10 @@ I like %COLOR% color Here is a link:index.html?USER=%USER%#liber-recusabo[link^] containing a query string item that should open to "Liber recusabo" in a new window +This link (link:index.html?USER=username#link-testing[index.html?USER=username]) that will set the `USER` querystring parameter to `username` and return to this section. + +This link should substitute the `USER` queryparam into the URL itself: link:index-%USER%.html?USER=%USER%#link-testing[index-%USER%.html^] + [#query-string-replacement-testing] == Query String Replacement Testing diff --git a/src/js/07-userparams-behaviour.js b/src/js/07-userparams-behaviour.js index 9a7058d..5e80843 100644 --- a/src/js/07-userparams-behaviour.js +++ b/src/js/07-userparams-behaviour.js @@ -78,8 +78,14 @@ document.addEventListener('DOMContentLoaded', function () { function applyPattern (str, key, value) { //(%25key%25|%key%) %25 is urlencode value of % - var pattern = '(' + '%25' + key + '%25' + - '|(?