We have a utility method called parseUrl in url.js that is used to parse a Url string.
This method caches the result of a parse so not to repeat for the same given Url however the cache used for this is unlimited which is no ideal.
The fix involved changing the cache map to be an LRU (Least Recently Used) cache with a large capacity (100).
Fortunately we have an implementation of LRU cache in lru-cache.js which we can use here.
closes Issue #13280 in the description. Once approved, your changes will be merged. ⚡⚡⚡Congrats on making your first contribution to the AMP Project!⚡⚡⚡ You'll be able to see it live across the web soon!
Thanks, and we hope to see more contributions from you soon.
If you have questions ask @aghassemi in this issue or on your Pull Request (if you've created one) or see the How to get help section of the Getting Started guide.
FYI, there is an LRU implemented in utils/lru-cache.js for you to reuse
While you're at it, make the LRU's cache a prototype-less object. 😉
@aghassemi I would like to take a shot at this issue if it is free.
@cjdeleon62 Thanks! Assigned to you.
@aghassemi awesome! I'll start working on it tonight 👍
Hi @aghassemi, this is my first time contributing to this repo and I just have a question about the unit tests. Some are consistently failing because they are trying to match the updated scrollTop values and the difference between the actual and expected is off by decimal places. Just wondering if this is only happening to me or is this expected to flake sometimes?
@cjdeleon62 they are flakes. If your own newly written tests pass, I recommend submitting a PR. All tests would run again on Travis as part of the PR and they are less flaky than localhost runs.
@aghassemi okay, that is good to know, will submit a PR soon. Thanks!
Closed by #13892