Skip to content

Instantly share code, notes, and snippets.

View kamrankamrani's full-sized avatar
💻
JsTs

kamrankamranifard kamrankamrani

💻
JsTs
View GitHub Profile
@kamrankamrani
kamrankamrani / serviceWorkerRegistration.js
Created May 26, 2022 12:40
service worker update pwa application
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
);
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {