Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

reactjs - Dot and hyphen disallowed React Router URL parameters?

I am working to implement an image viewer and using React Router. Uploaded image files are of the format <name>.<type-suffix>-<date-tag>, with a period and a hypen as delimiters.

Given this route: <Route path="zoomer/:imageId" component={ Zoom }/> and this URL http://localhost:8080/zoomer/medMain.tif-1461839237863 it does not seem that the router is finding a match.

If I remove the dot and the hyphen (e.g. http://localhost:8080/zoomer/medMaintif1461839237863) routing works just fine, but I really need to keep those delimiters for semantic reasons. And URLEncode() won't help me here, either.

Is there something I need to do with the Route spec to fix this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Adding this to your webpack devServer config also does the trick:

historyApiFallback: {
    disableDotRule: true
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...