URL Parser
This repository contains a work in progress state machine 100% compliant to the URL parser specification. The goal is to create a performant URL parser.
For more information about the URL parsing state machine visit here.
Installation
npm i --save url-state-machine
Usage
const URLStateMachine = require('url-state-machine')
const state = new URLStateMachine('https://www.yagiz.co/implementing-node-js-url-parser-in-webassembly-with-rust/')
console.log(state.url)
Benchmarks
Here's the current benchmarks comparing url-state-machine
with the native URL implementation and whatwg-url
.
Even though these benchmarks provide a good reference for url-state-machine
, should not be taken in any consideration since the implementation of url-state-machine
is not finished, and does not reflect the final performance of it.
╔═══════════════════╤═════════╤══════════════════╤═══════════╗
║ Slower tests │ Samples │ Result │ Tolerance ║
╟───────────────────┼─────────┼──────────────────┼───────────╢
║ whatwg-url │ 2000 │ 38352.06 op/sec │ ± 0.85 % ║
║ url-state-machine │ 2500 │ 74207.62 op/sec │ ± 0.89 % ║
╟───────────────────┼─────────┼──────────────────┼───────────╢
║ Fastest test │ Samples │ Result │ Tolerance ║
╟───────────────────┼─────────┼──────────────────┼───────────╢
║ URL │ 2000 │ 465722.37 op/sec │ ± 0.99 % ║
╚═══════════════════╧═════════╧══════════════════╧═══════════╝
Testing
All tests are referenced and borrowed from web-platform-tests.
Test Files 1 failed (1)
Tests 132 failed | 601 passed (733)
Time 548ms (in thread 53ms, 1034.30%)
Conformance to specification
We're currently testing only the following attributes for URL
- pathname
- 89 failed | 644 passed (733)
- host
- 32 failed | 701 passed (733)
- password
- 2 failed | 731 passed (733)
- protocol
- 1 failed | 732 passed (733)
- username
- 733 passed (733)
- port
- 733 passed (733)
- fragment
- 733 passed (733)
- query
- 733 passed (733)