Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update URL parsing logic (again). #1996

Merged
merged 1 commit into from
Apr 24, 2017

Conversation

seraku24
Copy link
Contributor

@seraku24 seraku24 commented Nov 8, 2016

This improves upon a fix I submitted earlier regarding the FlxStringUtil.getDomain() function, addressing some concerns I brought up to @Gama11. I wanted to submit this work now for greater visibility and general review, even though this is a fairly low priority item.

The main item is the introduction of a new public function, FlxStringUtil.getHost(), which takes care of proper URL parsing in a more robust manner. It supports nearly all of RFC 3986, with the only notable exception being the "IPvFuture" extension to IPv6. (I could not find any practical examples of the extension to use for testing, so I opted to omit it from the regex.) This moves the URL parsing logic out of the existing getDomain() function, which now focuses only on extracting the first- and second-level domains from a host.

Breaking change: The getDomain() function used to return "local" upon failure. This was undocumented behavior carried over from when it was it part of the FlxBasePreloader class. This PR changes the failure value to the empty string (""), which just feels like a better design for a public API. The necessary changes have been made to FlxBasePreloader, cleaning up its logic in the process.

Finally, the unit tests I introduced for getDomain() have been expanded upon to test getHost() as well.

Added a new FlxStringUtil.getHost function to handle the (nearly) proper URL parsing.
Updated FlxStringUtil.getDomain to use this new function.
!Breaking change: getDomain now returns the empty string ("") upon failure.  (Previous behavior was to return "local".)
Cleaned up logic in FlxBasePreloader.isHostUrlAllowed.
Removed conditional definition of FlxBasePreloader.LOCAL.  (Its value is no longer target-specific.)
Added new unit tests.
Refactor unit tests to allow code reuse.
@gamedevsam gamedevsam merged commit 5dfc1e8 into HaxeFlixel:dev Apr 24, 2017
@seraku24 seraku24 deleted the seraku24-url-parsing-iterum branch April 24, 2017 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants