- From: Claudia Meadows <notifications@github.com>
- Date: Tue, 29 Aug 2023 11:42:23 -0700
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/url/issues/782/1697952277@github.com>
> I'm not sure I follow… if you mean, select properties in a specific order to get to a mutable instance, and then mutate it, that seems fine to me.
@ljharb More like this:
1. Read scheme, parse scheme, skip slashes
1. Read host, parse host, skip colon + port steps
1. Read port, set port (parsing not needed)
1. Read path (with optional query), parse path + query
1. Read explicit query via `URLSearchParams` and merge it
1. Return resolved URL instance
The difference between option 1 and option 2 is this:
Option 1: each "parse" step work as follows:
1. Start with the right state.
- Scheme: scheme start state
- Host: authority state, but disallow initial `@`
- Path (`file:`): file host state
- Path (non-`file:`): path state
- Fragment: fragment state with optional `#` prefix
- Username and password might be a bit tricky, as they don't cleanly map to a specific parsing state
1. Ending states must be reached
- Scheme: scheme state, trailing `:` optional
- Host: host state
- Path (`file:`): path state or end
- Path (non-`file:`): path state, query state, or end
- Fragment: end
- Username and password might be a bit tricky, as they don't cleanly map to a specific parsing state
1. Some state transitions are errors:
- Scheme to anything but scheme start
- Authority to anything but host/hostname
- Path/query to fragment
- Path to query if `file:`
Username and password might be a bit tricky, as they don't cleanly map to a specific parsing state.
Option 2:
- Source is either a string or dictionary
- It iterates through that list, but within the loop through that layer of indirection.
- Instead of explicitly jumping directly into those states per option 1, it starts as normal (but setting the pointer to the first character of `origin`). Then, it reads each part in segments, switching through each source string.
- Example: in step 9 > scheme state > 2 in the basic URL parser (for dictionary options):
- An EOF must follow the colon.
- After setting the scheme, set the pointer to the first byte of `host` and the state to authority state.
Does this help?
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/782#issuecomment-1697952277
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/url/issues/782/1697952277@github.com>
Received on Tuesday, 29 August 2023 18:42:28 UTC