Open ces3001 opened 5 months ago
ps. replacing the last line with
let v = "{{VALUE}}";
return `[${v}](${convertPhoneNumberToLink(v)})`;
Still gives the wrong result. [+1-800-CALL-APPL](tel:+182583)
it doesn’t change the bug.
Please excuse the multiple follow-ups. It seems to me that QuickAdd isn’t replacing the {{VALUE}}
string in the code before the execution of the javascript, but only replacing it after in the javascript's output.
So it’s perhaps a bug, perhaps a design decision. For now, I guess, we request it as feature -> https://github.com/chhoumann/quickadd/issues/483
Describe the bug Using
js quickadd
in the Capture Fromat: whereval = “{{VALUE}}”
,val.replace
function assumes literal{{VALUE}}
, not selection, if grep matches something in the literal string”{{VALUE}}”
, otherwise leaves selection. If you simplyreturn val
, it returns the selection.To Reproduce
will incorrectly return
{{9ALUE}}
as theV
matches in{{VALUE}}
.{{VALUE}}
seemingly doesn’t get replaced with the selected text, but is taken literally.Whereas, omitting the
V
in the grep pattern:This will do nothing, and correctly return the selected text (not
{{VALUE}}
), because/[WXYZwxyz]/g
doesn’t match anything in the string{{VALUE}}
.Expected behavior replace should use the replacement selection string. In the example above, depending on the selection. If selection =
VWA
, then replaced with99A
, not{{9ALUE}}
Desktop (please complete the following information):
Additional context I’m trying to implement a “Convert Phone to Link” function:
This will always return
[ACTUAL PHONE NUMBER SELECTED](tel:82583)
because 82582 is VALUE on the numeric keypad.