How to use the excludePattern in camel for the remove headers? - apache-camel

I tried to work with the camel's remove header which works for some and does not work for other patterns
It works for the below patterns
<removeHeaders pattern="*" />
<removeHeaders pattern="CamelFile*" />
It does not work for
<removeHeaders pattern="*File*" />
Is the above expected?
Also in the exclude pattern I observe that the wildcard patterns * is not recognised at all.
<setHeader headerName="firstCustomHeader">
<constant>firstCustomHeader</constant>
</setHeader>
<setHeader headerName="secondCustomHeader">
<constant>secondCustomHeader</constant>
</setHeader>
<setHeader headerName="thirdCustomHeader">
<constant>thirdCustomHeader</constant>
</setHeader>
<setHeader headerName="fourthCustomHeader">
<constant>fourthCustomHeader</constant>
</setHeader>
<removeHeaders pattern="*" excludePattern="fourth*|third*" />
the above removes all the header but does excludes the excludePattern value
How do I achieve the relevant above mentioned pattern?
Camel Version 2.13.1

You could accomplish the removeHeaders **File** using the following pattern:
pattern="\w+File\w+"
Similarly, your excludePattern can also be achieved using:
excludePattern="fourth\w+|third\w+"
These are basically regular expressions that can be tested here.

Yes either use a regular expression or use a single * in the end as
wildcard. So *File* is not valid, as it has two *, and therefore Camel assumes its a regular expression.
So you should do a regular expression
pattern=".*File.*"
Where as if you have only one * its a shorthand for matching wildcards, but the * must be only once and at the end of the line, such as
pattern="File*"
The syntax is documented here
http://camel.apache.org/intercept

Related

eslint custom rule - disable specific html elements in jsx syntax

I would like to know how is it possible to create a custom rule, where I can define fobidden html elements in jsx syntax.
For example, I want to be sure that only <Button /> and <Input /> compontents from my ui library are used. If <input> or <button> html elements are used in jsx, eslint should throw an error.
If you want to create an ESLint rule by yourself (e.g. to learn something new) then this won't be helpful and it's certainly out of scope for a StackOverflow question, but if you need it for practical reasons, there is already a rule that does exactly what you want.

React, dynamically change part of a route

I have read up on dynamic routes, but haven't found a solution that worked for me. I am working on a project where, when I click next, I want the routes to change as follows:
/part1/4
/part1/3
/part1/2
/part1/1
/part2/4
/part2/3
/part2/2
/part2/1
…
/part5/4
/part5/3
/part5/2
/part5/1
And of course if I click back, it should back through the routes.
I have this in App.js:
<Route path='/:part/:score' exact component={Questionnaire} />
But I'm not sure what I would need to put into the "to" part to change the /part1/ to part2, 3, 4, et.c at the appropriate time.
<Link to={`/part1/${scoreNum}`} id="next" onClick={this.disablePrevSelection} className={`btn btn-normal btn-green ${disabled}`}>Next ></Link>
I apologize in advance if this is a simple question as I am new to ReactJs. Please let me know if anything else is needed.
Thank you!
Your route should be like this:
<Route path='/path' component={Questionnaire} />
Note that we omitted exact here so that we can match every route starting with path
And link to it would be something like:
<Link to={`/part${partNum}/${scoreNum}`} id="next" onClick={this.disablePrevSelection} className={`btn btn-normal btn-green ${disabled}`}>Next ></Link>

InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('/static/media/index.c6592bb6.ts') is not a valid name

I have a react app that I am trying to convert to use typescript
but I'm getting the following error: InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('/static/media/index.c6592bb6.ts') is not a valid name.
What does this error even mean? It looks like it doesn't like the typescript extension
Any ideas how to fix?
In my case, I was building my web app and I had created a javaScript file in the IDE IntelliJ. But in the folder, the file name was missing the suffix ".js". So when I used 'npm run dev' command in the terminal, it failed to find the file I had created.
If it is the same for you, then just go to the folder and add the suffix ".js" in the file name.
I think it's a bug in IntelliJ, Hopefully they may fix it later on.
In my case, it was just importing asset like this
import { ReactComponent as PaintIcon } from "./assets/paint.svg";
instead of
import PaintIcon from "./assets/paint.svg";
Thanks.
There might be a dummy file in the name of index which not having ".js" as the suffix.
Or Your index file might not have ".js" suffix.
So rename it
The problem for me was that I was trying to render ts files. React can't 'create elements' from ts files. TS files need to be transpiled to JS. I thought that my babel loader was configured correctly but it wasn't. The babel loader wasn't checking for ts or tsx files.
in my case i was importing SVG like:
import SidebarButton from '../../assets/images/sidebarbutton.svg';
And just using that:
<SideBarButtonImg>
This fixed the issue:
const SideBarButtonImg = () => (
<button style={{height: '100%'}}>
<img
src={sidebarbutton}
alt=""
style={{
height: '100%',
background: '#fff',
}}
/>
</button>
)
I got this error also and I don't see it described in the solutions was a mistake on my part of having quotes as part of my Route component assignment.
<Route component="{ NotFound }" />
Removing the quotes solved the issue.
<Route component={ NotFound } />
It means you have code trying to do this:
document.createElement("/static/media/index.c6592bb6.ts")
...directly or indirectly. Since /static/media/index.c6592bb6.ts isn't a valid tag name (like div or span), it fails.
Just in case it hasn't been specified before, I had the same issue with Home document and it was because I used this:
<Route path="/" component="{Home}" />
Instead of this
<Route path="/" component={Home} />
Note the quote marks. Hope this helps someone.
Not sure if this Helps but I had the same error message and it was flagging the following:
ReactDOM.render ( <App />, document.getElementById('root'));
For me it was a simple mistake (as mentioned by someone already) of not having the file with correct extension. In my case it was SearchBox child that was saved as a text file and not as "SearchBox.js". In your case it would be the "Index" file. Granted I am completely new to this and am still learning, just thought I would share as reading previous responses to your question helped me fix my issue!
First of all, check that there is a file in your source folder or in public folder with no proper extension mean's like "
index
" add a proper extension to it or delete it.
haha, I have the same error and bothered me for a long time.
import GuessLikeList from './GuessLikeList/GuessLikeList.jsx';
and error
Failed to execute 'createElement' on 'Document': The tag name provided ('./GuessLikeList/GuessLikeList.jsx') is not a valid name.
It means can not execute with '.jsx',so you have to change filename extension or import some modules to compile jsx
I got this error. It happened that the name of the js folder had spaces at the end of it. Seems React doesn't recognise space in folder/file names.
In my own case, I had the error in my App.js. The App.js had a wrong name on the route path like this So I had to correct the path name and that fixed my error.
make sure you added .js at the name of your file as well as when you import it

Where can I found the placeholder schema for camel?

I want to use the following syntax to define a property attribute in a camel context like this:
<aggregate prop:completionSize="my.property" completionTimeout="1500" strategyRef=MyAggregationStrategy">
....
</aggregate>
and I cannot find anymore the schema xmlns:prop="http://camel.apache.org/schema/placeholder
How can I solve this problem?

AngularJS element directives not displaying when using self-closing tags

I have in my html file directives
<add />
<back />
and the directives are on the form
.directive('add', ['$window', ...
and
.directive('back', ['$window',
This works fine.
If i change the directives to camel case:
.directive('addPlayer', ['$window', ...
<add_player />
<back />
and
<add:player />
<back />
display fine whereas
<add-player /> regular dash
<back />
displays only <add-player> and everything after is not displayed.
Any ideas why?
EDIT:
I've kind of gotten the same behaviour here
http://plnkr.co/edit/cpP4c2TyZwv5Y4BrNUBb?p=preview
To lay your question to rest, I am quoting the official statement from the AngularJS team: (sic)
self-closing or void elements as the html spec defines them are very special to the browser parser. you can't make your own, so for your custom elements you have to stick to non-void elements (<foo></foo>).
this can't be changed in angular.
- IgorMinar
source: https://github.com/angular/angular.js/issues/1953#issuecomment-13135021
Follow the rest of the conversation on AngularJS issue's page where they discuss the possibility of using XHTML for delivering content with self-closing tags that is acceptable to the browser. However do note that it is not fully supported by AngularJS.
HTML spec does not allow self-closing tags on non-void elements.
HTML syntax rules [W3C]
Elements have a start tag to indicate where they begin. Non-void elements have an end tag to indicate where they end.
Start tags consist of the following parts, in exactly the following order:
A "<" character.
The element’s tag name.
Optionally, one or more attributes, each of which must be preceded by one or more space characters.
Optionally, one or more space characters.
Optionally, a "/" character, which may be present only if the element is a void element.
A ">" character.
There is a limited number of void elements in HTML5 spec. Here is the complete list:
area, base, br, col, command, embed, hr, img, input, keygen, link, meta, param, source, track, wbr.
What's really going on
The browser's parser has to listen to the spec. Since using the slash in a non-void element tag is invalid, the parser ignores the ending />, and <back /> means <back>. Therefore you are never closing the first element which prevents the others to work.
On Plunker you have:
<body>
<back></back>
Self closing <back />
Self closing <back />
</body>
which parses into
<body>
<back></back>
Self closing <back>
Self closing <back>
</back>
</back>
</body>
You then specify template: '<button>back</button>' on your directive which replaces back (and it's children) with the specified HTML resulting in:
<body>
<back>
<button>back</button>
</back>
Self closing <back>
<button>back</button>
</back>
</body>
What should I do then?
Use <back></back> for all and it will work fine. Alternatively you could use element attributes: <div back="attr"></div>.
See the following discussions for more details:
Q: Are self-closing tags valid in HTML5?
AngularJS - Custom directives with self-closing tags capture tag siblings.
AngularJS - Self-closing directives not always rendering.
I've run into the same problem recently and managed to fix it by not using self-closing tags. Try <add-player></add-player> instead of the self-closing version.
I don't know why self-closing tags don't work with dashes in the directive's tag name. Did a quick research back in the day and didn't find anything on the HTML/XHTML side. Perhaps a bug/limitation in Angular?
Angular v15.1.0 now has added support to self-closing tags on custom elements.
Check it out: https://github.com/angular/angular/blob/main/CHANGELOG.md

Resources