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

The has() method of the "PreviewCache" class probably won't work #41

Open
sounisi5011 opened this issue Aug 2, 2019 · 1 comment
Open
Labels
bug Something isn't working

Comments

@sounisi5011
Copy link
Owner

sounisi5011 commented Aug 2, 2019

The has() method should verify whether the cache data corresponding to the url specified in the argument exists.
However, the code when using the flat-cache package is probably not in line with its purpose.

See line 47:

public has(url: string): boolean {
if (this._store instanceof Map) {
return this._store.has(url);
} else {
return this.isCachedPreviewResponseJSON(this._store.all().url);
}
}

This code always looks like reading the cached data stored in the url property.

Is the correct code not this? :

return this.isCachedPreviewResponseJSON(this._store.all()[url]);
//                                                       ^^^^^
@sounisi5011 sounisi5011 added the bug Something isn't working label Aug 2, 2019
@sounisi5011
Copy link
Owner Author

Thank you for pointing out important issues!
Perhaps I wrote this code while sleeping 💦

Fortunately, we do not use the PreviewCache class has() method at now.
has() method was added to make it work as a Map class compatible interface.

However, this bug may cause problems if you use the has() method in the future.
This project requires test code of PreviewCache class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant