Comments (4)
Applying this patch to remove the 'global' flag is meeting my needs. But I'm not sure this change keeps the original intent.
diff --git a/node_modules/fastify-openapi-glue/lib/oai-formats.js b/node_modules/fastify-openapi-glue/lib/oai-formats.js
index 78f8de4..0f663bb 100644
--- a/node_modules/fastify-openapi-glue/lib/oai-formats.js
+++ b/node_modules/fastify-openapi-glue/lib/oai-formats.js
@@ -2,7 +2,7 @@ const Decimal = require('decimal.js-light');
function validateByte() {
// regExp borrowed from https://github.com/miguelmota/is-base64
- var regex = new RegExp('^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\/]{3}=)?$','gm');
+ var regex = new RegExp('^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\/]{3}=)?$','m');
return (value => value !== '' && regex.test(value))
}
from fastify-openapi-glue.
It's a bug, thanks for reporting.
Removing the g
would only check if the first line of the string is base64 and not the whole string.
The solution is to recreate the RexExp on every call as mentioned in: https://stackoverflow.com/questions/1520800/why-does-a-regexp-with-global-flag-give-wrong-results
I have created a patch.
Kind regards,
Hans
from fastify-openapi-glue.
Just published the patched version as 2.4.1 on npm.
Thanks again for reporting,
Hans
from fastify-openapi-glue.
Thanks for looking into this so quickly. Version 2.4.1 is working as expected in my project.
from fastify-openapi-glue.
Related Issues (20)
- Middleware HOT 3
- [email protected] deprecation notice (FSTDEP012) "Request#context will be removed in `fastify@5` HOT 4
- No validation error when non `application/json` response provided by API HOT 2
- Return route options from operationResolver HOT 2
- [Discussion] [Request] Rename `service` => `handlers` in options HOT 4
- Suggestion about the TS imports errors HOT 7
- using "example" in swagger api HOT 7
- PARAMETERS method is not supported: when using cross-method parameters HOT 3
- Schema validation HOT 2
- Presence of cookie not being validated HOT 5
- and connected security requirements not possible. HOT 7
- Multiple Security Handlers Error Handling HOT 4
- "Error: 'specification' parameter must contain a valid version" when trying to reference schema from another file HOT 6
- FEATURE REQUEST: Mark some routes as unrouted/static (no operationId logic) HOT 3
- References getting stripped from response HOT 2
- TypeScript template for fastify-openapi-glue cli? HOT 2
- `opts` ignored in default template? HOT 6
- Compression doesn't work HOT 1
- PR for no-dependency cookie support? HOT 7
- Type generation for handlers HOT 9
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 fastify-openapi-glue.