GithubHelp home page GithubHelp logo

Comments (4)

bnacey avatar bnacey commented on August 19, 2024

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.

seriousme avatar seriousme commented on August 19, 2024

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.

seriousme avatar seriousme commented on August 19, 2024

Just published the patched version as 2.4.1 on npm.

Thanks again for reporting,
Hans

from fastify-openapi-glue.

bnacey avatar bnacey commented on August 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.