Giter VIP home page Giter VIP logo

accept-header's People

Contributors

coriolinus avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

wallaroolabs

accept-header's Issues

Don't depend on `mime` crate

It seems like mime is "rotting" and it's unclear if this will change in the future. Meanwhile, alternatives like mediatype already exist. Perhaps this crate should proactively drop mime and build on more modern foundations.

Ordering bug

There appears to be a bug in the implementation. For example, consider this test case:

diff --git a/src/lib.rs b/src/lib.rs
index 22cfc31..074c2be 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -243,4 +243,22 @@ mod tests {
         let expect = &[("application/json", 1.0, None)];
         perform_test(input, expect);
     }
+
+    #[test]
+    fn ordering_bug() {
+        let input = "Accept: image/webp,image/avif,image/jxl,image/heic,image/heic-sequence,video/*;q=0.8,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5";
+        let expect = &[
+            ("image/webp", 1.0, None),
+            ("image/avif", 1.0, None),
+            ("image/jxl", 1.0, None),
+            ("image/heic", 1.0, None),
+            ("image/heic-sequence", 1.0, None),
+            ("image/png", 1.0, None),
+            ("image/svg+xml", 1.0, None),
+            ("video/*", 0.8, None),
+            ("image/*", 0.8, None),
+            ("*/*", 0.5, None),
+        ];
+        perform_test(input, expect);
+    }
 }

Where implied quality should be 1.0 it's rendering as None and for some reason avif is ordered before webp. This seems like an incorrect parsing of the example Accept value (taken from Safari).

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.