You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2022/04/27 12:27:06 UTC

[camel-website] branch main updated: Remove all the formatting characters from the id to prevent invalid url generation (#833)

This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-website.git


The following commit(s) were added to refs/heads/main by this push:
     new 04f9e4e1 Remove all the formatting characters from the id to prevent invalid url generation (#833)
04f9e4e1 is described below

commit 04f9e4e190dc441b1204ac9b6c9a46c725576d1d
Author: Nicolas Filotto <es...@users.noreply.github.com>
AuthorDate: Wed Apr 27 14:27:00 2022 +0200

    Remove all the formatting characters from the id to prevent invalid url generation (#833)
    
    ## Motivation
    
    If the text provided to the `boldLink` function contains special formatting characters of asciidoc, the generation of the URL fails, consequently the website cannot be built due to an error of the next type:
    
    ```
    [check:links ] Found invalid urls in components/next/mongodb-component.html:
    [check:links ] Fragment #_endpoint_header%3C/em%3Eid at components/next/mongodb-component.html does not exist!
    ```
    In the previous example the provided text is `_id` which contains an underscore that is one of the formatting character of asciidoc
    
    ## Modification
    
    * Update the `boldLink` function to remove all the special characters from the provided text used to generate the link
---
 util/jsonpath-util.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/util/jsonpath-util.js b/util/jsonpath-util.js
index b558324f..38255927 100644
--- a/util/jsonpath-util.js
+++ b/util/jsonpath-util.js
@@ -38,7 +38,8 @@ module.exports = {
   },
 
   boldLink: (text, idPrefix, suffix = '') => {
-    const idText = `_${idPrefix}_${text.split('.').join('_')}`
+    // Remove all the formatting characters from the id to prevent invalid url generation
+    const idText = `_${idPrefix}_${text.split(/[*_`#~^]*/g).join('').split('.').join('_')}`
     text = suffix ? `*${text}* (${suffix})` : `*${text}*`
     return  `[[${idText}]]\nxref:#${idText}['',role=anchor]${text}`
   },