Skip to content

Latest commit

 

History

History

reference-implementation

Reference Implementation and Tests

This folder contains a reference implementation of the URL standard.

  • urlparse.js is generated from a common source as the specification, namely url.pegjs.

  • The reference implementation also contains a Live DOM URL Viewer which is deployed online.

  • A test suite is included inside test.

Historical notes

I started this effort by attempting to create a faithful implementation of the URL Standard. Like others who attempted to do so, I found the current description to appear to be easy to follow yet when I attempted to do so I found I had a hard time determining what should be the parsing output for a number of cases. I ended up reverse engineering the outputs, and actually reading the source code, of other implementations.

This kinda defeats the purpose of a Spec.

I then embarked on an effort to define a formal grammar and selected PEG.js. For the parts which aren't covered by the grammar, I used a path of least resistance: a tool to convert Ruby to JS.

Had I started from scratch, I likely would have followed the lead of the streams reference implementation and used ES6 and traceur.

Plans / Todos

  • Eliminate the ruby2js step and maintain the generated JavaScript instead. For the moment, I still prefer to think in terms of higher level abstractions like class and instance methods than what ES5 provides, but longer term I recognize that will be an impediment to others participating.

  • Settle on some sort of "JavaDoc" like syntax which would enable bikeshed flavored syntax to be included as comments and automatically extracted during the build process for the purposes of spec generation.

  • Find or build a compliant JavaScript implementation of the Encoding Living Standard. Until then, the reference implementation tracks and updates the value of encoding_override, but doesn't use it. Instead utf-8 is always used.