Comments (10)
What do you mean by a dot in your dynamic route? Something like
https://mysite.com/sub/a.b.c/
?
from kobweb.
OK took a minute to try this out. Not only is this broken but it also looks like there's an issue with dynamic slugs in general (e.g. "/sub/{token}"
) seem to be busted even without a dot in the middle!
Will look into this soon, seems like a bad bug. Thanks for the report!
from kobweb.
So here's the culprit:
val extension = pathQueryAndFragment.substringAfterLast('/').substringAfterLast('.', "")
What this means is the route "a/b.c/d/e" is treated as having the file extension "c/d/e". Whoops!
I'm definitely going to fix this to allow dots in the middle of paths (so b.c
) is allowed.
@AC-Lover Do you also need to support dots in the final slug as well? That is, do you need to support a/b/stuff.here.with.dot
as well? Because if so I need to think about it.
from kobweb.
So here's the culprit:
val extension = pathQueryAndFragment.substringAfterLast('/').substringAfterLast('.', "")What this means is the route "a/b.c/d/e" is treated as having the file extension "c/d/e". Whoops!
I'm definitely going to fix this to allow dots in the middle of paths (so
b.c
) is allowed.@AC-Lover Do you also need to support dots in the final slug as well? That is, do you need to support
a/b/stuff.here.with.dot
as well? Because if so I need to think about it.
https://regex101.com/r/KXfm0z/1
My requirement is this, please check
from kobweb.
Apologies as life keeps throwing chores at me these holiday break days but fixing this is my highest priority once I get some time to code. I will put up a 0.15.4-SNAPSHOT you can use when it's ready. I'll ping this bug at that point.
I'm hoping once I actually get some time to code, a fix will be pretty fast, especially now I can repro and know the area of the code I need to fix.
from kobweb.
FYI initially looking into this and ktor doesn't seem to like being asked to serve a route with a period in it. When I ask ktor for a path associated with a "." slug, I get a 404. Of course, it could be my own configuration of ktor that Kobweb sets up. Investigating.
It dawned on me that you might be able to work around this for now by removing the "." from the token and replacing it with another character, say "_", and then translating it back to a "." right before you send it back to JWT (which I assume happens on your backend).
You might also communicate the token using a JSON message via a request/response body rather than via query parameters, although I'm not 100% sure what your requirements are. (See kobweb create examples/todo
for an example of sending data back and forth with JSON payloads)
I'll keep you in the loop as I figure more things out.
from kobweb.
OK so good news but also a limitation.
- I fixed query parameters, so they can accept periods in them now (e.g.
route?token=a.b.c
). - You can now use periods elsewhere inside your route path (so something like
docs/2.0/
will work)
That said, I'm giving up on supporting "." inside the slug.
A period inside a slug is valid, but it is generally assumed that when this is done you're trying to declare a file (as far as I can tell). Even ktor seems to think this way -- it tries to figure out the extension to know what sort of content it's going to send over the wire. When it encounters a dot inside a slug and doesn't know what the extension is, it returns an error response.
In your case, I would restrict the token to a query parameter, as in https://yoursite.com/sub/?token=this.has.dots.in.it
. If you really don't want to do this for some reason, I would consider base64 encoding the token and then decoding it later. (base64 is limited to alphanumerics)
I've uploaded a snapshot to 0.15.4-SNAPSHOT
. Can you try setting your gradle/libs.version.toml
file to that version and let me know if you are unblocked?
from kobweb.
@bitspittle
Thank you very much for your help, but I need the /sub/{JWT} structure and there is no way I can change this structure to another form, because I am actually trying to create a website interface for a tool, and this structure /sub/{JWT} is determined by that tool.
If I understood correctly, the problem is almost solved, right?
from kobweb.
Sadly the problem is not almost solved because ktor is failing to handle it and it's not at all clear why. In other words, the failure at this point seems to be ktor, not Kobweb.
And unfortunately I do have other priorities at the moment so I don't have much time to jump into something deep in ktor.
What is this tool you're talking about which generates a URL you can't change?
from kobweb.
Sadly the problem is not almost solved because ktor is failing to handle it and it's not at all clear why. In other words, the failure at this point seems to be ktor, not Kobweb.
And unfortunately I do have other priorities at the moment so I don't have much time to jump into something deep in ktor.
What is this tool you're talking about which generates a URL you can't change?
I am not in a hurry, and you can solve this problem whenever you are comfortable and I am currently working as quayParameter until the problem is completely solved.
Thank you for your help and follow-up. Have a nice day 🙌
from kobweb.
Related Issues (20)
- Support specifying a script for Web Workers HOT 1
- `favicon` and `script` are referenced by absolute path making them inaccessible with static export HOT 5
- Add opinionated solution to API routes to reduce boilerplate. HOT 3
- Links with fragments don't work in markdown HOT 3
- Extract out a `kotlin-js-ext` module from `compose-html-ext` HOT 1
- Allow Hash-Based Routing HOT 2
- Generated FaIcons.kt badly indentated HOT 2
- Support transferable objects with web workers HOT 2
- [IJ plugin] Show miniature of Fa and Mdi Icons in the gutter HOT 1
- Losing original pages when generating new ones via KSP HOT 4
- Support for Material Symbols
- Inline code markdown links disappear HOT 3
- Add TOC to the README HOT 4
- Support Compose Resources? HOT 5
- Documentation on how to change website favicon HOT 7
- Implement a background video feature HOT 2
- backdrop-filter blur not working in Safari HOT 2
- How to implement a file picker
- Support PWA apps
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kobweb.