peterhellberg / link Goto Github PK
View Code? Open in Web Editor NEWParses Link headers used for pagination, as defined in RFC 5988
Home Page: https://tools.ietf.org/html/rfc5988
License: MIT License
Parses Link headers used for pagination, as defined in RFC 5988
Home Page: https://tools.ietf.org/html/rfc5988
License: MIT License
Please use semantic versioning:
If multiple Links are given as multiple headers rather than a single comma separated value, only the first value is returned.
github.com/golang/gddo/httputil/header.ParseList might be useful here.
(Reporting in case it is helpful.)
The following input causes Parse
to panic:
link.Parse(`</example.png>;rel=preload;as=image`)
(Playground link: https://go.dev/play/p/yZcgx_-7G_4.)
The input comes from the real world and may or may not be valid. (From a quick look over RFC 5988, it seems that it might be okay.)
The panic can be minified to link.Parse("</example.png>; rel=preload")
. It seems it happens when there aren't double quotes around the rel value.
I suspect PR #5 may fix it. (CC @AlaricWhitney)
Link header from: http://www.w3.org/wiki/LinkHeader
Link: <//www.w3.org/wiki/LinkHeader>; rel="original latest-version",<//www.w3.org/wiki/Special:TimeGate/LinkHeader>; rel="timegate",<//www.w3.org/wiki/Special:TimeMap/LinkHeader>; rel="timemap"; type="application/link-format"; from="Mon, 03 Sep 2007 14:52:48 GMT"; until="Tue, 16 Jun 2015 22:59:23 GMT",<//www.w3.org/wiki/index.php?title=LinkHeader&oldid=10152>; rel="first memento"; datetime="Mon, 03 Sep 2007 14:52:48 GMT",<//www.w3.org/wiki/index.php?title=LinkHeader&oldid=84697>; rel="last memento"; datetime="Tue, 16 Jun 2015 22:59:23 GMT"
runtime error: index out of range
github.com/peterhellberg/link.Parse(0xc82015a000, 0x21b, 0x1)
/go/src/github.com/peterhellberg/link/link.go:83 +0x66c
github.com/peterhellberg/link.ParseHeader(0xc8200f4840, 0x0)
/go/src/github.com/peterhellberg/link/link.go:54 +0xd0
github.com/peterhellberg/link.ParseResponse(0xc82011c1b0, 0x4a3959)
/go/src/github.com/peterhellberg/link/link.go:48 +0x3a
main.main.func3(0xc82011c1b0, 0xc820110050, 0xc8200cb901)
/go/src/app/main.go:42 +0x28
I think this being caused by the commas in datetime values.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.