-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AG-37031 Fix link breakage due to deletion of amp string. #102
Squashed commit of the following: commit 00428fd Author: jellizaveta <[email protected]> Date: Thu Oct 24 13:39:42 2024 +0300 fix issue with selectors, remove redundant conditions commit a04db2a Author: jellizaveta <[email protected]> Date: Wed Oct 23 19:28:06 2024 +0300 clean added links too commit 7aad8cc Author: jellizaveta <[email protected]> Date: Wed Oct 23 18:14:01 2024 +0300 update changelog commit 84a2333 Author: jellizaveta <[email protected]> Date: Wed Oct 23 18:05:01 2024 +0300 fix vars, update config commit bda23bf Author: Slava Leleka <[email protected]> Date: Wed Oct 23 17:01:15 2024 +0300 CHANGELOG.md edited online with Bitbucket commit 56c2a9b Author: jellizaveta <[email protected]> Date: Wed Oct 23 16:23:49 2024 +0300 remove watch from webpack config commit a1a5d36 Author: jellizaveta <[email protected]> Date: Wed Oct 23 16:20:56 2024 +0300 remove redundant func commit 2c6e95d Author: jellizaveta <[email protected]> Date: Wed Oct 23 16:15:28 2024 +0300 remove replacement/deletion of 'amp' string in links, added watch mode for debugging, rewrite the code for redirects commit 395d5b0 Author: jellizaveta <[email protected]> Date: Tue Oct 22 18:27:04 2024 +0300 update meta commit 27450a7 Author: jellizaveta <[email protected]> Date: Tue Oct 22 18:22:34 2024 +0300 update changes commit 29f0a1b Author: jellizaveta <[email protected]> Date: Tue Oct 22 18:21:38 2024 +0300 limit fix commit 4ccec6d Author: jellizaveta <[email protected]> Date: Tue Oct 22 18:21:22 2024 +0300 limit fix commit a4e9314 Author: Slava Leleka <[email protected]> Date: Tue Oct 22 16:17:45 2024 +0300 CHANGELOG.md edited online with Bitbucket commit 70c3d83 Author: Slava Leleka <[email protected]> Date: Tue Oct 22 16:04:39 2024 +0300 src/google-amp.js edited online with Bitbucket commit 8d2c257 Author: jellizaveta <[email protected]> Date: Tue Oct 22 15:59:51 2024 +0300 update changelog commit 8b57d25 Author: jellizaveta <[email protected]> Date: Tue Oct 22 15:57:36 2024 +0300 AG-37031 handle cases where amp should be replaced by HTML file extension. #102
- Loading branch information
1 parent
59f05d4
commit 7d17631
Showing
8 changed files
with
1,569 additions
and
2,301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,39 @@ | ||
import { redirectTurboPages } from './yandex-turbo'; | ||
import { redirectAmpProjectPages } from './amp-project'; | ||
import { preventNewsAmp, preventAmp, ampRedirect } from './google-amp'; | ||
import { | ||
preventNewsAmp, | ||
replaceCdnAmp, | ||
ampRedirect, | ||
cleanAmpLink, | ||
} from './google-amp'; | ||
import { observeDomChanges } from './utils'; | ||
|
||
const SEARCH_PATH = '/search'; | ||
const GOOGLE_NEWS_PATH = 'news.google.'; | ||
const GOOGLE_PATH = 'google.'; | ||
const YANDEX_TURBO_PATH = 'https://yandex.ru/turbo'; | ||
const TURBOPAGES_PATH = 'turbopages.org'; | ||
|
||
(() => { | ||
const { href, origin } = document.location; | ||
|
||
if (href.includes('https://yandex.ru/turbo') || href.includes('turbopages.org')) { | ||
if (href.includes(YANDEX_TURBO_PATH) || href.includes(TURBOPAGES_PATH)) { | ||
redirectTurboPages(); | ||
return; | ||
} | ||
|
||
if (!origin.includes('.google.')) { | ||
// clean links in google search result to prevent them from open in iframe | ||
if (origin.includes(GOOGLE_PATH) && href.includes(SEARCH_PATH)) { | ||
observeDomChanges(cleanAmpLink); | ||
} | ||
|
||
// redirect only amp links | ||
if (!origin.includes(GOOGLE_PATH)) { | ||
ampRedirect(); | ||
redirectAmpProjectPages(); | ||
return; | ||
} | ||
|
||
if (origin.includes('news.google.')) { | ||
if (origin.includes(GOOGLE_NEWS_PATH)) { | ||
observeDomChanges(preventNewsAmp); | ||
} else { | ||
observeDomChanges(preventAmp); | ||
observeDomChanges(replaceCdnAmp); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.