Understood. In that case, the code will have to be made more complex...
Here's a quick attempt .. Can you please have a look at it?
(defun modi/ffap-string-at-point (&optional mode)
"Return a string of characters from around point.
MODE (defaults to value of `major-mode') is a symbol used to look up
string syntax parameters in `ffap-string-at-point-mode-alist'.
If MODE is not found, we use `file' instead of MODE.
If the region is active,return a string from the region.
If the point is in a comment, ensure that the returned string does not contain
the comment start characters (especially for major modes that have '//' as
comment start characters).
Sets variables `ffap-string-at-point' and `ffap-string-at-point-region'. "
(let* ((args
(cdr
(or (assq (or mode major-mode) ffap-string-at-point-mode-alist)
(assq 'file ffap-string-at-point-mode-alist))))
(region-selected (use-region-p))
(pt (point))
(beg (if region-selected
(region-beginning)
(save-excursion
(skip-chars-backward (car args))
(skip-chars-forward (nth 1 args) pt)
(point))))
(end (if region-selected
(region-end)
(save-excursion
(skip-chars-forward (car args))
(skip-chars-backward (nth 2 args) pt)
(point))))
beg-temp)
;; Ensure that if "//" is a valid comment starter in the current major
;; mode, then that is removed from the returned string.
(when (and (null region-selected)
;; Check if the first character is '/' and not part of the
;; comment
(save-excursion
(goto-char beg)
(and (looking-at "/")
(null (nth 4 (syntax-ppss)))))
;; Check if the second character is '/' and also not part of
;; the comment
(setq beg-temp (+ 1 beg))
(if (> end beg-temp)
(save-excursion
(goto-char beg-temp)
(and (looking-at "/")
(null (nth 4 (syntax-ppss)))))
nil))
;; Check if the third character *is* part of the comment
(setq beg-temp (+ 2 beg))
(if (> end beg-temp)
(save-excursion
(goto-char beg-temp)
(when (nth 4 (syntax-ppss))
(setq beg beg-temp)))))
(message "beg = %d beg-temp = %S end = %d "
beg beg-temp end)
(prog1
(setq ffap-string-at-point
(buffer-substring-no-properties
(setcar ffap-string-at-point-region beg)
(setcar (cdr ffap-string-at-point-region) end)))
(message "dbg: %S" ffap-string-at-point)
)))
(advice-add 'ffap-string-at-point :override #'modi/ffap-string-at-point)