PokaInc / arnparse

Parse ARNs using Python
MIT License
36 stars 6 forks source link

fix: Case where there is both a "resourcetype" and path in the "resou… #4

Closed spg closed 5 years ago

spg commented 5 years ago

…rce"

Fixes https://github.com/PokaInc/arnparse/issues/3

ebickle commented 5 years ago

Looks good. You can improve performance a bit by removing the call to .split and using slice notation instead. E.g.

        separator = resource[first_separator_index]
        resource_type, resource = resource.split(separator, 1)

becomes

    resource_type = resource[:first_separator_index]
    resource = resource[first_separator_index+1:]

A sanity check / unit test for a single delimiter at the end of the original resource string might not be a bad idea if you don't have one already - I'm writing this up from memory and haven't personally tested the edge cases for the code above.

spg commented 5 years ago

@ebickle thanks for the suggestion! Done in 6626331