├── .eslintrc ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── 1-Bug-report.md │ ├── 2-Enhancement.md │ └── 3-Feature-request.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── assets ├── Deeplink-Banner.png ├── Deeplink-Banner@2x.png ├── Deeplink-Logo.png └── Deeplink-Logo@2x.png ├── babel.config.json ├── jest.config.json ├── package-lock.json ├── package.json ├── prepublish └── package.json ├── src ├── apps │ ├── facebook-link-app.ts │ ├── instagram-link-app.ts │ ├── reddit-link-app.ts │ ├── snapchat-link-app.ts │ ├── tiktok-link-app.ts │ ├── twitter-link-app.ts │ └── youtube-link-app.ts ├── deep-linker.ts ├── generator.ts ├── index.ts ├── link-app-mapping.ts └── link-app.ts ├── tests └── deep-linker.test.ts └── tsconfig.json /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "browser": true, 5 | "node": true 6 | }, 7 | "parser": "@typescript-eslint/parser", 8 | "plugins": [ 9 | "@typescript-eslint" 10 | ], 11 | "parserOptions": { 12 | "sourceType": "module", 13 | "ecmaVersion": 2017 14 | }, 15 | "rules": { 16 | "no-shadow": "off", 17 | "no-param-reassign": "off", 18 | "indent": "off", 19 | "space-before-function-paren": "off", 20 | "quotes": "off", 21 | "comma-dangle": "off", 22 | "no-unused-vars": "off", 23 | "no-console": "off", 24 | "arrow-parens": "off", 25 | "dot-notation": "off", 26 | "no-trailing-spaces": "off", 27 | "semi": [ 28 | 2, 29 | "always" 30 | ] 31 | } 32 | } -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Neutron Repos ✨ 2 | 3 | Our code is open and free for anyone to use, forever. We love to have people share and give back to the community! 4 | 5 | There are many ways to contribute to our projects! 6 | 7 | - Testing open [issues](https://github.com/neutron-creative/deeplink/issues) or [pull requests](https://github.com/neutron-creative/deeplink/issues) and sharing your findings in a comment. 8 | - Testing beta versions and release candidates. 9 | - Submitting fixes, improvements, and enhancements. 10 | - To disclose a security issue to our team, please submit a report to us privately using our communications channel: contact@neutroncreative.com 11 | 12 | If you wish to contribute code, please read the information in the sections below. Then [fork](https://help.github.com/articles/fork-a-repo/) the project, commit your changes, and [submit a pull request](https://help.github.com/articles/using-pull-requests/) 🎉 13 | 14 | Most of our projects are licensed under the GPLv3+, and all contributions to the project will be released under the same license. You maintain copyright over any contribution you make, and by submitting a pull request, you agree to release that contribution under the GPLv3+ license. 15 | This project is licensed under LGPL v2.1, and you maintain any rights included with that license. 16 | 17 | If you have questions about the process to contribute code or want to discuss details of your contribution, you can contact core developers on discord in the [Neutron community Discord](https://discord.gg/BUbmgV4). 18 | Feel free to join our Discord if you just want to chat with us, too! We're always happy to talk to the community. 19 | 20 | ## Getting started 21 | 22 | Every repo should have an installation process laid out in the README.md file. If it doesn't, feel free to let a project maintainer know! 23 | All projects should have a well documented installation process. 24 | 25 | ## Coding Guidelines and Development 26 | 27 | ### Overall Guidelines 28 | 1. Make sure to use proper coding standards based on the project. Not all projects will follow the same standard based on the language and technology, so pay attention! 29 | 2. Every project should have a unified linter or code-style checker. Please do not modify these. 30 | 3. Never contribute broken, uncompilable, or non-styled code. 31 | 4. If a project has unit testing guidelines, please make sure to follow them before submitting a pull request. 32 | 5. The master branch should always be compilable. Use feature-branches to save unstable code. 33 | 6. Do not modify license files unless otherwise stated. 34 | 35 | ### Contributors 36 | 1. Delete feature branches after you are done with them to keep the repo clean. 37 | 2. Tag major and minor releases. 38 | 39 | ## Feature Requests 40 | 41 | - Please check our roadmap before asking for a feature request. 42 | - You may submit feature requests on our [issues](https://github.com/neutron-creative/deeplink/issues) tracker. 43 | 44 | ## Pull Request Process 45 | 46 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a build. 47 | 2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters. 48 | 3. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is SemVer. 49 | 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you. 50 | 51 | ## Code of Conduct 52 | 53 | ### Our Pledge 54 | 55 | In the interest of fostering an open and welcoming environment, we as 56 | contributors and maintainers pledge to making participation in our project, and 57 | our community a harassment-free experience for everyone, regardless of age, body 58 | size, disability, ethnicity, gender identity and expression, level of experience, 59 | nationality, personal appearance, race, religion, or sexual identity and 60 | orientation. 61 | 62 | ### Our Standards 63 | 64 | Examples of behavior that contributes to creating a positive environment 65 | include: 66 | 67 | * Using welcoming and inclusive language 68 | * Being respectful of differing viewpoints and experiences 69 | * Gracefully accepting constructive criticism 70 | * Focusing on what is best for the community 71 | * Showing empathy towards other community members 72 | 73 | Examples of unacceptable behavior by participants include: 74 | 75 | * The use of sexualized language or imagery and unwelcome sexual attention or 76 | advances 77 | * Trolling, insulting/derogatory comments, and personal or political attacks 78 | * Public or private harassment 79 | * Publishing others' private information, such as a physical or electronic 80 | address, without explicit permission 81 | * Other conduct which could reasonably be considered inappropriate in a 82 | professional setting 83 | 84 | ### Our Responsibilities 85 | 86 | Project maintainers are responsible for clarifying the standards of acceptable 87 | behavior and are expected to take appropriate and fair corrective action in 88 | response to any instances of unacceptable behavior. 89 | 90 | Project maintainers have the right and responsibility to remove, edit, or 91 | reject comments, commits, code, wiki edits, issues, and other contributions 92 | that are not aligned to this Code of Conduct, or to ban temporarily or 93 | permanently any contributor for other behaviors that they deem inappropriate, 94 | threatening, offensive, or harmful. 95 | 96 | ### Scope 97 | 98 | This Code of Conduct applies both within project spaces and in public spaces 99 | when an individual is representing the project or its community. Examples of 100 | representing a project or community include using an official project e-mail 101 | address, posting via an official social media account, or acting as an appointed 102 | representative at an online or offline event. Representation of a project may be 103 | further defined and clarified by project maintainers. 104 | 105 | ### Enforcement 106 | 107 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 108 | reported by contacting the project team at contact@neutroncreative.com. All 109 | complaints will be reviewed and investigated and will result in a response that 110 | is deemed necessary and appropriate to the circumstances. The project team is 111 | obligated to maintain confidentiality with regard to the reporter of an incident. 112 | Further details of specific enforcement policies may be posted separately. 113 | 114 | Project maintainers who do not follow or enforce the Code of Conduct in good 115 | faith may face temporary or permanent repercussions as determined by other 116 | members of the project's leadership. 117 | 118 | ### Attribution 119 | 120 | This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.4, 121 | available at [http://contributor-covenant.org/version/1/4](http://contributor-covenant.org/version/1/4/) -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/1-Bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F41E Bug report" 3 | about: Report a bug if something isn't working as expected. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Please provide us with the information requested in this bug report. Without these details, we won't be able to fully evaluate this issue. 11 | Bug reports lacking detail, or for any other reason than to report a bug, may be closed without action. 12 | 13 | **Prerequisites (mark completed items with an [x]):** 14 | - [ ] I have have carried out troubleshooting steps and I believe I have found a bug. 15 | - [ ] I have searched for similar bugs in both open and closed issues and cannot find a duplicate. 16 | 17 | **Describe the bug** 18 | A clear and concise description of what the bug is. 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Actual behavior** 24 | A clear and concise description of what actually happens. Please be as descriptive as possible; 25 | 26 | **Steps to reproduce the bug (We need to be able to reproduce the bug in order to fix it.)** 27 | Steps to reproduce the bug: 28 | 1. Go to '...' 29 | 2. Click on '....' 30 | 3. Scroll down to '....' 31 | 4. See error 32 | 33 | **Screenshots** 34 | If applicable, add screenshots to help explain your problem. -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/2-Enhancement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "✨ New Enhancement" 3 | about: If you have an idea to improve an existing feature or need something for development please let us know or submit a Pull Request! 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/3-Feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F680 Feature request" 3 | about: "Suggest a new feature \U0001F389 We'll consider building it if it receives sufficient interest! \U0001F44D" 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Changes proposed in this Pull Request: 2 | 3 | 4 | 5 | Closes # . 6 | 7 | ### How to test the changes in this Pull Request: 8 | 9 | 1. 10 | 2. 11 | 3. 12 | 13 | ### Other information: 14 | 15 | 16 | 17 | ### Changelog entry 18 | 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | lib 3 | node_modules 4 | .vim 5 | .idea 6 | .eclipse 7 | .atom 8 | .vscode 9 | .run 10 | .nuxt -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). 9 | 10 | ## [Unreleased](https://github.com/Neutron-Creative/Deeplink/compare/v1.0.5...HEAD) 11 | 12 | ### Commits 13 | 14 | - Restructure again [`5351c18`](https://github.com/Neutron-Creative/Deeplink/commit/5351c18793ea45b0f5d27fab92dfae9bba91272f) 15 | - Create CODE_OF_CONDUCT.md [`e049af8`](https://github.com/Neutron-Creative/Deeplink/commit/e049af846772465c6a5095d49bf19015ba220712) 16 | - Update changelog [`5cc731a`](https://github.com/Neutron-Creative/Deeplink/commit/5cc731a9963e3cebb94ecd79160a9f20c9122f5d) 17 | - Update build scripts [`db80661`](https://github.com/Neutron-Creative/Deeplink/commit/db806619e0a480d2fbe9f93466d2505c7edd50dd) 18 | - Update paths [`543c723`](https://github.com/Neutron-Creative/Deeplink/commit/543c72344fc71cb4501dbb8f8fd558264a0b4192) 19 | - Update README.md [`607d776`](https://github.com/Neutron-Creative/Deeplink/commit/607d7764afd46609b9697318e90c42d3e5ba889a) 20 | 21 | ## [v1.0.5](https://github.com/Neutron-Creative/Deeplink/compare/v1.0.4...v1.0.5) - 2020-09-26 22 | 23 | ### Commits 24 | 25 | - Fix project structure entirely [`7462372`](https://github.com/Neutron-Creative/Deeplink/commit/74623722b1e170130e7502ae8e01bc8a6adfebd4) 26 | - Update package [`1610d39`](https://github.com/Neutron-Creative/Deeplink/commit/1610d392682fd0307d6aa0b69767ad88acfdc45a) 27 | 28 | ## [v1.0.4](https://github.com/Neutron-Creative/Deeplink/compare/v1.0.3...v1.0.4) - 2020-09-25 29 | 30 | ### Commits 31 | 32 | - Update package [`c3aa3ea`](https://github.com/Neutron-Creative/Deeplink/commit/c3aa3eae39055ccef7826be4ca4c0892105c62af) 33 | 34 | ## [v1.0.3](https://github.com/Neutron-Creative/Deeplink/compare/v1.0.2...v1.0.3) - 2020-09-25 35 | 36 | ### Commits 37 | 38 | - Update structure [`57a5756`](https://github.com/Neutron-Creative/Deeplink/commit/57a575634bfc7b43c16f289dba9db5a806966dab) 39 | - Update package [`8d5d27f`](https://github.com/Neutron-Creative/Deeplink/commit/8d5d27ff688ca937610a0b8216d5079a02dd8103) 40 | 41 | ## [v1.0.2](https://github.com/Neutron-Creative/Deeplink/compare/v1.0.1...v1.0.2) - 2020-09-25 42 | 43 | ### Commits 44 | 45 | - Fix package structure [`3c3c19e`](https://github.com/Neutron-Creative/Deeplink/commit/3c3c19e23cc34cc84f1a11fd0764ce8aa58d8ac2) 46 | - Update CHANGELOG [`f16bb8c`](https://github.com/Neutron-Creative/Deeplink/commit/f16bb8c2a1c39c2767d4c216e6ecdcc776353b83) 47 | 48 | ## [v1.0.1](https://github.com/Neutron-Creative/Deeplink/compare/v1.0.0...v1.0.1) - 2020-09-25 49 | 50 | ### Commits 51 | 52 | - Update package [`08690df`](https://github.com/Neutron-Creative/Deeplink/commit/08690dfd115b762c40b69f803b59154aa8683013) 53 | - Update CHANGELOG [`519d56a`](https://github.com/Neutron-Creative/Deeplink/commit/519d56abaef1b6092b40477bde0b2390c97fea06) 54 | - Update README and CHANGELOG [`4f0e1c9`](https://github.com/Neutron-Creative/Deeplink/commit/4f0e1c9dcf382a022d786e5111a626bb951c0e5e) 55 | 56 | ## v1.0.0 - 2020-09-25 57 | 58 | ### Commits 59 | 60 | - Initial commit [`4383145`](https://github.com/Neutron-Creative/Deeplink/commit/4383145f10bb2de5e96a52a3b0282424afc9366f) 61 | - Update LICENSE [`cccbce3`](https://github.com/Neutron-Creative/Deeplink/commit/cccbce39390dfaa27919e8f772a7d1b25cfd69d0) 62 | - Add the rest of the LinkApps [`dd6f911`](https://github.com/Neutron-Creative/Deeplink/commit/dd6f911ad2fe91f822efe6dfd68182c6efc43adf) 63 | - Rename project [`5e8f96b`](https://github.com/Neutron-Creative/Deeplink/commit/5e8f96b1d930243e5a8b71a5648b99f9f7adbf9e) 64 | - Update README and CHANGELOG [`9af0035`](https://github.com/Neutron-Creative/Deeplink/commit/9af003542a79a087683cc0badcc64a4b643a2873) 65 | - Initial commit [`06a08f1`](https://github.com/Neutron-Creative/Deeplink/commit/06a08f1b4c654307b192c5df1684539d21f85f5f) 66 | - Fix typo in tests, they all pass now [`57179cc`](https://github.com/Neutron-Creative/Deeplink/commit/57179ccb0890997a391fdbb538e082d6ad8905bf) 67 | - update Changelog [`19eddb4`](https://github.com/Neutron-Creative/Deeplink/commit/19eddb4781976165081ead6e296f7f751dcf7351) 68 | - Update for index.ts [`23eda64`](https://github.com/Neutron-Creative/Deeplink/commit/23eda645d57afdc3ae11c405f8c3e9fa9fa9e75e) 69 | - Update config to keep comments, and fix inaccurate readme [`0675407`](https://github.com/Neutron-Creative/Deeplink/commit/0675407077ae1fc0bf1d89a9f35ace141f7d0680) 70 | - Fix documentation [`eaa84d6`](https://github.com/Neutron-Creative/Deeplink/commit/eaa84d6ba814b7e668684f700c3b3ec1e737c498) 71 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at contact@neutroncreative.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 489 | USA 490 | 491 | Also add information on how to contact you by electronic and paper mail. 492 | 493 | You should also get your employer (if you work as a programmer) or your 494 | school, if any, to sign a "copyright disclaimer" for the library, if 495 | necessary. Here is a sample; alter the names: 496 | 497 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 498 | library `Frob' (a library for tweaking knobs) written by James Random 499 | Hacker. 500 | 501 | , 1 April 1990 502 | Ty Coon, President of Vice 503 | 504 | That's all there is to it! 505 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |
3 |
4 | 5 |
6 |
7 |

8 | 9 |
10 | 11 |

12 | A simple library to convert your links to deep links. 13 |

14 | 15 |

16 | 17 | Version 18 | 19 | 20 | License 21 | 22 | 23 | 24 | 25 |

26 | 27 |

28 | 29 | Twitter Follow 30 | 32 | 33 | 34 |

35 | 36 |

37 | Key features • 38 | Installation • 39 | Pre-requisites • 40 | Creating deep links • 41 | Related 42 |

43 |
44 | 45 | Deeplink promotional graphic 46 | 47 |
48 | 49 |

Key features

50 | 51 | - Convert links into deep links 52 | - Pass a user agent to correctly determine which link to provide 53 | - Automatically fallback to default URL if a type can't be determined 54 | - Support for many platforms 55 | - Twitter 56 | - Instagram 57 | - Facebook 58 | - Reddit 59 | - TikTok 60 | - SnapChat 61 | - YouTube 62 | - ...and more coming soon! 63 | - 100% free and open-source 64 | 65 |
66 | 67 |

Installation

68 | 69 | ##### npm 70 | ```bash 71 | npm i nc-deeplink 72 | ``` 73 | 74 | ##### yarn 75 | ```bash 76 | yarn add nc-deeplink 77 | ``` 78 | 79 | ## Compiling 80 | ```sh 81 | # install dependencies 82 | npm install 83 | 84 | # (optional) install typescript globally 85 | npm install typescript -g 86 | 87 | # build the library (automatically copies important files and compiles typescript) 88 | npm run build 89 | ``` 90 |
91 |

Pre-requisites

92 | DeepLink uses user agents to determine a valid destination for a link. 93 | You can grab this user agent any way you need to. 94 | 95 | ### Import 96 | ```ts 97 | import {DeepLinker} from "nc-deeplink"; 98 | 99 | // or 100 | 101 | const Index = require("nc-deeplink"); 102 | ``` 103 | 104 |
105 | 106 | 107 | #### Parse a Deep Link 108 | ```ts 109 | import {DeepLinker} from "nc-deeplink"; 110 | 111 | let userAgent = navigator.userAgent; 112 | let deepLink = DeepLinker.parseDeepLink(url, userAgent); 113 | 114 | console.log(deepLink); 115 | ``` 116 | 117 | #### Create an OS specific Deep Link (no user agent needed) 118 | ```ts 119 | import {DeepLinker} from "nc-deeplink"; 120 | 121 | let deepLink = DeepLinker.convertToDeepLink(url, "Android"); 122 | console.log(deepLink); 123 | 124 | deepLink = DeepLinker.convertToDeepLink(url, "iOS"); 125 | console.log(deepLink); 126 | 127 | ``` 128 | 129 | #### Check if a user agent is mobile 130 | ```ts 131 | import {DeepLinker} from "nc-deeplink"; 132 | 133 | let userAgent = navigator.userAgent; 134 | let isMobile = DeepLinker.isMobile(url, userAgent); 135 | console.log(isMobile) 136 | ``` 137 | 138 | ### Deep Link Mapping with Link Apps 139 | Link Apps are how DeepLink figures out how to convert a link into a deep link. 140 | DeepLink provides a number of mappings by default, but if you wish to add more, you may do so. 141 | 142 | #### Add a mapping 143 | ```ts 144 | import {DeepLinkGenerator} from "nc-deeplink"; 145 | import {LinkApp} from "nc-deeplink"; 146 | 147 | class RedditLinkApp extends LinkApp { 148 | constructor(url?: string) { 149 | super(url, "reddit.com", undefined, "com.reddit.frontpage"); 150 | } 151 | 152 | getAndroidLink(): string { 153 | return `intent://${this.appUrl}/${this.pathname}#Intent;package=${this.appPackage};scheme=https;end`; 154 | } 155 | 156 | getiOSLink(): string { 157 | return this.originalUrl; 158 | } 159 | } 160 | 161 | DeepLinkGenerator.mappings.push(new RedditLinkApp()); 162 | ``` 163 | 164 |
165 | 166 | 167 |

Singlelink is Neutron Creative product, created and hosted free of charge in the mission of open-source. To learn more about our mission, visit neutroncreative.com

168 | 169 |

Be sure to check out our other products as well!

170 |
    171 |
  • Capture, Simplified screenshot API (https://capture.neutron.so)
  • 172 |
  • Sponsorware, Sell software with Github Sponsors (https://sponsorware.neutron.so)
  • 173 |
  • Cowlytics, Real-time Stripe analytics & forcesting for SaaS (https://www.cowlytics.co)
  • 174 |
  • Neutron, Faster websites in one-click (https://neutroncreative.com)
  • 175 |
-------------------------------------------------------------------------------- /assets/Deeplink-Banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Neutron-Creative/Deeplink/9a71c048f278882d99ec68c4194fef04ffd97295/assets/Deeplink-Banner.png -------------------------------------------------------------------------------- /assets/Deeplink-Banner@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Neutron-Creative/Deeplink/9a71c048f278882d99ec68c4194fef04ffd97295/assets/Deeplink-Banner@2x.png -------------------------------------------------------------------------------- /assets/Deeplink-Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Neutron-Creative/Deeplink/9a71c048f278882d99ec68c4194fef04ffd97295/assets/Deeplink-Logo.png -------------------------------------------------------------------------------- /assets/Deeplink-Logo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Neutron-Creative/Deeplink/9a71c048f278882d99ec68c4194fef04ffd97295/assets/Deeplink-Logo@2x.png -------------------------------------------------------------------------------- /babel.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "targets": { 7 | "node": "current" 8 | } 9 | } 10 | ] 11 | ] 12 | } -------------------------------------------------------------------------------- /jest.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "ts-jest", 3 | "testEnvironment": "node", 4 | "timers": "fake" 5 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nc-deeplink", 3 | "version": "1.0.6", 4 | "description": "A library for creating deep links from regular links.", 5 | "scripts": { 6 | "build": "tsc", 7 | "copy": "(copyfiles -f \"prepublish/package.json\" \"./lib\")", 8 | "build-and-copy": "npm run build && npm run copy", 9 | "version": "auto-changelog && git add CHANGELOG.md", 10 | "test": "jest", 11 | "test-debug": "jest --runInBand --detectOpenHandles", 12 | "prepare": "npm run build-and-copy" 13 | }, 14 | "main": "lib/index.js", 15 | "types": "lib/index.d.ts", 16 | "files": [ 17 | "lib/**/*" 18 | ], 19 | "auto-changelog": { 20 | "output": "CHANGELOG.md", 21 | "template": "keepachangelog", 22 | "unreleased": true, 23 | "commitLimit": false 24 | }, 25 | "repository": { 26 | "type": "git", 27 | "url": "git+https://github.com/Neutron-Creative/deeplink.git" 28 | }, 29 | "keywords": [ 30 | "deep", 31 | "links", 32 | "link", 33 | "links", 34 | "neutron", 35 | "creative", 36 | "neutron", 37 | "creative", 38 | "deep", 39 | "seo", 40 | "marketing", 41 | "uiux", 42 | "ui", 43 | "ux" 44 | ], 45 | "author": "Neutron Creative Inc.", 46 | "license": "LGPL-2.1-only", 47 | "bugs": { 48 | "url": "https://github.com/Neutron-Creative/deeplink/issues" 49 | }, 50 | "homepage": "https://github.com/Neutron-Creative/deeplink#readme", 51 | "dependencies": { 52 | "ua-parser-js": "^0.7.22" 53 | }, 54 | "devDependencies": { 55 | "@babel/core": "^7.11.6", 56 | "@babel/preset-env": "^7.11.5", 57 | "@babel/preset-typescript": "^7.10.4", 58 | "@types/jest": "^26.0.13", 59 | "@types/node": "^14.10.1", 60 | "@types/ua-parser-js": "^0.7.33", 61 | "@typescript-eslint/eslint-plugin": "^3.9.1", 62 | "@typescript-eslint/parser": "^3.9.1", 63 | "auto-changelog": "^2.2.0", 64 | "babel-jest": "^26.3.0", 65 | "copyfiles": "^2.4.0", 66 | "eslint": "^7.7.0", 67 | "jest": "^26.4.2", 68 | "ts-jest": "^26.3.0", 69 | "ts-node": "^9.0.0", 70 | "typescript": "^3.9.7" 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /prepublish/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nc-deeplink", 3 | "version": "1.0.6", 4 | "description": "A library for creating deep links from regular links.", 5 | "scripts": { 6 | "version": "auto-changelog && git add CHANGELOG.md", 7 | "test": "jest", 8 | "test-debug": "jest --runInBand --detectOpenHandles" 9 | }, 10 | "main": "index.js", 11 | "types": "index.d.ts", 12 | "files": [ 13 | "**/*" 14 | ], 15 | "auto-changelog": { 16 | "output": "CHANGELOG.md", 17 | "template": "keepachangelog", 18 | "unreleased": true, 19 | "commitLimit": false 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "git+https://github.com/Neutron-Creative/deeplink.git" 24 | }, 25 | "keywords": [ 26 | "deep", 27 | "links", 28 | "link", 29 | "links", 30 | "neutron", 31 | "creative", 32 | "neutron", 33 | "creative", 34 | "deep", 35 | "seo", 36 | "marketing", 37 | "uiux", 38 | "ui", 39 | "ux" 40 | ], 41 | "author": "Neutron Creative Inc.", 42 | "license": "LGPL-2.1-only", 43 | "bugs": { 44 | "url": "https://github.com/Neutron-Creative/deeplink/issues" 45 | }, 46 | "homepage": "https://github.com/Neutron-Creative/deeplink#readme", 47 | "dependencies": { 48 | "ua-parser-js": "^0.7.22" 49 | }, 50 | "devDependencies": { 51 | "@babel/core": "^7.11.6", 52 | "@babel/preset-env": "^7.11.5", 53 | "@babel/preset-typescript": "^7.10.4", 54 | "@types/jest": "^26.0.13", 55 | "@types/node": "^14.10.1", 56 | "@types/ua-parser-js": "^0.7.33", 57 | "@typescript-eslint/eslint-plugin": "^3.9.1", 58 | "@typescript-eslint/parser": "^3.9.1", 59 | "auto-changelog": "^2.2.0", 60 | "babel-jest": "^26.3.0", 61 | "copyfiles": "^2.4.0", 62 | "eslint": "^7.7.0", 63 | "jest": "^26.4.2", 64 | "ts-jest": "^26.3.0", 65 | "ts-node": "^9.0.0", 66 | "typescript": "^3.9.7" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/apps/facebook-link-app.ts: -------------------------------------------------------------------------------- 1 | import {LinkApp} from "../link-app"; 2 | 3 | export class FacebookLinkApp extends LinkApp { 4 | constructor(url?: string) { 5 | super(url, "facebook.com", "fb", "com.facebook.katana"); 6 | } 7 | 8 | getAndroidLink(): string { 9 | return `intent://${this.pathname}#Intent;package=${this.appPackage};scheme=fb;end`; 10 | } 11 | 12 | getiOSLink(): string { 13 | return `${this.protocolPrefix}://${this.pathname}` 14 | } 15 | } -------------------------------------------------------------------------------- /src/apps/instagram-link-app.ts: -------------------------------------------------------------------------------- 1 | import {LinkApp} from "../link-app"; 2 | 3 | export class InstagramLinkApp extends LinkApp { 4 | constructor(url?: string) { 5 | super(url, "instagram.com", "instagram", "com.instagram.android"); 6 | } 7 | 8 | getAndroidLink(): string { 9 | return `intent://${this.appUrl}/${this.pathname}#Intent;package=${this.appPackage};scheme=https;end`; 10 | } 11 | 12 | getiOSLink(): string { 13 | return `${this.protocolPrefix}://${this.pathname}` 14 | } 15 | } -------------------------------------------------------------------------------- /src/apps/reddit-link-app.ts: -------------------------------------------------------------------------------- 1 | import {LinkApp} from "../link-app"; 2 | 3 | export class RedditLinkApp extends LinkApp { 4 | constructor(url?: string) { 5 | super(url, "reddit.com", undefined, "com.reddit.frontpage"); 6 | } 7 | 8 | getAndroidLink(): string { 9 | return `intent://${this.appUrl}/${this.pathname}#Intent;package=${this.appPackage};scheme=https;end`; 10 | } 11 | 12 | getiOSLink(): string { 13 | return this.originalUrl; 14 | } 15 | } -------------------------------------------------------------------------------- /src/apps/snapchat-link-app.ts: -------------------------------------------------------------------------------- 1 | import {LinkApp} from "../link-app"; 2 | 3 | export class SnapchatLinkApp extends LinkApp { 4 | constructor(url?: string) { 5 | super(url, undefined, "snapchat", "com.snapchat.android"); 6 | } 7 | 8 | getAndroidLink(): string { 9 | return `intent://${this.pathname}#Intent;package=${this.appPackage};scheme=snapchat;end`; 10 | } 11 | 12 | getiOSLink(): string { 13 | return `${this.protocolPrefix}://${this.pathname}` 14 | } 15 | } -------------------------------------------------------------------------------- /src/apps/tiktok-link-app.ts: -------------------------------------------------------------------------------- 1 | import {LinkApp} from "../link-app"; 2 | 3 | export class TikTokLinkApp extends LinkApp { 4 | constructor(url?: string) { 5 | super(url, "tiktok.com", "snssdk1233", "com.zhiliaoapp.musically"); 6 | } 7 | 8 | getAndroidLink(): string { 9 | return `intent://${this.appUrl}/${this.pathname}#Intent;package=${this.appPackage};scheme=snssdk1233;end`; 10 | } 11 | 12 | getiOSLink(): string { 13 | return `${this.protocolPrefix}://${this.pathname}` 14 | } 15 | } -------------------------------------------------------------------------------- /src/apps/twitter-link-app.ts: -------------------------------------------------------------------------------- 1 | import {LinkApp} from "../link-app"; 2 | 3 | export class TwitterLinkApp extends LinkApp { 4 | constructor(url?: string) { 5 | super(url, "twitter.com", "twitter", "com.twitter.android"); 6 | } 7 | 8 | getAndroidLink(): string { 9 | return `intent://${this.appUrl}/${this.pathname}#Intent;package=${this.appPackage};scheme=https;end`; 10 | } 11 | 12 | getiOSLink(): string { 13 | return `${this.protocolPrefix}://${this.pathname}` 14 | } 15 | } -------------------------------------------------------------------------------- /src/apps/youtube-link-app.ts: -------------------------------------------------------------------------------- 1 | import {LinkApp} from "../link-app"; 2 | 3 | export class YoutubeLinkApp extends LinkApp { 4 | constructor(url?: string) { 5 | super(url, "www.youtube.com", "vnd.youtube", "com.google.android.youtube"); 6 | } 7 | 8 | getAndroidLink(): string { 9 | return `intent://${this.appUrl}/${this.pathname}#Intent;package=${this.appPackage};scheme=https;end`; 10 | } 11 | 12 | getiOSLink(): string { 13 | return `${this.protocolPrefix}://${this.pathname}` 14 | } 15 | } -------------------------------------------------------------------------------- /src/deep-linker.ts: -------------------------------------------------------------------------------- 1 | import {UAParser} from "ua-parser-js"; 2 | import {DeepLinkGenerator} from "./generator"; 3 | 4 | export class DeepLinker { 5 | /** 6 | * Parses a url and returns a deep link if the user agent represents a mobile device. 7 | * If it doesn't, it returns the url as is. 8 | * 9 | * @param url The url to potentially turn into a deep link 10 | * @param userAgent The user agent to be parsed 11 | */ 12 | static parseDeepLink(url: string, userAgent: string): string { 13 | if (this.isMobile(userAgent)) { 14 | let parser = new UAParser(userAgent); 15 | let os = parser.getOS().name; 16 | 17 | if (os) { 18 | let deepLink = this.convertToDeepLink(url, os); 19 | 20 | if (deepLink) 21 | return deepLink; 22 | } 23 | 24 | return url; 25 | } 26 | 27 | return url; 28 | } 29 | 30 | /** 31 | * Converts a link to a deep link. If the OS is not supported, it returns the url as unchanged. 32 | * 33 | * @param url The url to convert. 34 | * @param os The operating system that is being targeted. 35 | */ 36 | static convertToDeepLink(url: string, os: string): string { 37 | switch (os) { 38 | case "Android": 39 | return DeepLinkGenerator.createAndroidDeepLink(url); 40 | case "iOS": 41 | return DeepLinkGenerator.createiOSDeepLink(url); 42 | default: 43 | return url; 44 | } 45 | } 46 | 47 | /** 48 | * Determines if a UserAgent is a mobile device or not. 49 | * @param userAgent 50 | */ 51 | static isMobile(userAgent: string): boolean { 52 | let parser = new UAParser(userAgent); 53 | 54 | switch (parser.getDevice().type) { 55 | case "mobile": 56 | return true; 57 | case "tablet": 58 | return true; 59 | default: 60 | return false; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /src/generator.ts: -------------------------------------------------------------------------------- 1 | import {LinkApp} from "./link-app"; 2 | import {LinkAppMapping} from "./link-app-mapping"; 3 | import {TwitterLinkApp} from "./apps/twitter-link-app"; 4 | import {InstagramLinkApp} from "./apps/instagram-link-app"; 5 | import {FacebookLinkApp} from "./apps/facebook-link-app"; 6 | import {RedditLinkApp} from "./apps/reddit-link-app"; 7 | import {TikTokLinkApp} from "./apps/tiktok-link-app"; 8 | import {SnapchatLinkApp} from "./apps/snapchat-link-app"; 9 | import {YoutubeLinkApp} from "./apps/youtube-link-app"; 10 | 11 | export class DeepLinkGenerator { 12 | /** 13 | * All the mappings available to the Deep Link Generator. 14 | * More may be added. 15 | */ 16 | static mappings: LinkAppMapping[] = [ 17 | new LinkAppMapping("twitter.com", new TwitterLinkApp()), 18 | new LinkAppMapping("instagram.com", new InstagramLinkApp()), 19 | new LinkAppMapping("facebook.com", new FacebookLinkApp()), 20 | new LinkAppMapping("reddit.com", new RedditLinkApp()), 21 | new LinkAppMapping("tiktok.com", new TikTokLinkApp()), 22 | new LinkAppMapping("snapchat.com", new SnapchatLinkApp()), 23 | new LinkAppMapping("youtube.com", new YoutubeLinkApp()), 24 | ]; 25 | 26 | /** 27 | * Creates an Android based Deep Link based on the url provided. 28 | * Automatically determines the app type based on the url if no LinkApp is provided. 29 | * @param url 30 | * @param linkApp 31 | */ 32 | 33 | static createAndroidDeepLink(url: string, linkApp?: LinkApp): string { 34 | if (linkApp) { 35 | return linkApp.getAndroidLink() ?? url; 36 | } else { 37 | let findApp = this.findApp(url); 38 | if (!findApp) return url; 39 | 40 | return findApp?.getAndroidLink() ?? url; 41 | } 42 | } 43 | 44 | /** 45 | * Creates an iOS based Deep Link based on the url provided. 46 | * Automatically determines the app type based on the url if no LinkApp is provided. 47 | * @param url 48 | * @param linkApp 49 | */ 50 | static createiOSDeepLink(url: string, linkApp?: LinkApp): string { 51 | if (linkApp) { 52 | return linkApp.getiOSLink() ?? url; 53 | } else { 54 | let findApp = this.findApp(url); 55 | if (!findApp) return url; 56 | 57 | return findApp?.getiOSLink() ?? url; 58 | } 59 | } 60 | 61 | private static findApp(url: string): LinkApp | undefined { 62 | for (let mapping of this.mappings) { 63 | if (url.includes(mapping.searchString)) { 64 | let clonedLinkApp: LinkApp = Object.create(mapping.linkApp); 65 | clonedLinkApp.setUrl(url); 66 | 67 | return clonedLinkApp; 68 | } 69 | } 70 | 71 | return undefined; 72 | } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./deep-linker"; 2 | export * from "./generator"; 3 | export * from "./link-app"; 4 | export * from "./link-app-mapping"; -------------------------------------------------------------------------------- /src/link-app-mapping.ts: -------------------------------------------------------------------------------- 1 | import {LinkApp} from "./link-app"; 2 | 3 | /** 4 | * Provides a mapping between an "includes" search string, and a LinkApp. 5 | * Allows DeepLink to find a Link App based on the pattern. 6 | */ 7 | export class LinkAppMapping { 8 | searchString: string; 9 | linkApp: LinkApp; 10 | 11 | constructor(searchString: string, linkApp: LinkApp) { 12 | this.searchString = searchString; 13 | this.linkApp = linkApp; 14 | } 15 | } -------------------------------------------------------------------------------- /src/link-app.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The base LinkApp class. You can use this to make a new LinkApp type, which is how the deep link is generated. 3 | */ 4 | export abstract class LinkApp { 5 | originalUrl: string = ""; 6 | pathname: string = ""; 7 | 8 | /** 9 | * Base URL of the application. 10 | */ 11 | appUrl: string = ""; 12 | 13 | /** 14 | * Protocol prefix of the application. 15 | */ 16 | protocolPrefix: string = ""; 17 | 18 | /** 19 | * Android app package for android intents. 20 | */ 21 | appPackage: string = ""; 22 | 23 | /** 24 | * 25 | * @param url The url that needs to be parsed 26 | * @param appUrl The base url of the application 27 | * @param protocolPrefix 28 | * @param appPackage Android app package 29 | * @protected 30 | */ 31 | protected constructor(url?: string, appUrl?: string, protocolPrefix?: string, appPackage?: string) { 32 | if (url) this.setUrl(url); 33 | if (appUrl) this.setAppUrl(appUrl); 34 | if (protocolPrefix) this.setProtocolPrefix(protocolPrefix); 35 | if (appPackage) this.setAppPackage(appPackage); 36 | } 37 | 38 | setUrl(url: string) { 39 | this.originalUrl = url; 40 | 41 | let urlObject = new URL(url); 42 | this.pathname = urlObject.pathname.slice(1, urlObject.pathname.length) 43 | } 44 | 45 | setAppUrl(appUrl: string) { 46 | this.appUrl = appUrl; 47 | } 48 | 49 | setProtocolPrefix(protocolPrefix: string) { 50 | this.protocolPrefix = protocolPrefix; 51 | } 52 | 53 | setAppPackage(appPackage: string) { 54 | this.appPackage = appPackage; 55 | } 56 | 57 | /** 58 | * Should return the most basic Android deep link strategy possible, 59 | * which is appending the URL parameters to the deep link url. 60 | */ 61 | abstract getAndroidLink(): string; 62 | 63 | /** 64 | * Should return the most basic iOS deep link strategy possible, 65 | * which is appending the URL parameters to the deep link url. 66 | */ 67 | abstract getiOSLink(): string; 68 | } -------------------------------------------------------------------------------- /tests/deep-linker.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User Agents come from https://www.whatismybrowser.com/guides/the-latest-user-agent 3 | */ 4 | 5 | import {UAParser} from "ua-parser-js"; 6 | import {DeepLinker, DeepLinkGenerator} from "../src"; 7 | 8 | let testData = [ 9 | "https://twitter.com/NeutronCreative", 10 | "https://www.instagram.com/NeutronCreative", 11 | "https://www.facebook.com/NeutronCreative", 12 | "https://reddit.com/u/NeutronCreative", 13 | "https://tiktok.com/NeutronCreative", 14 | "https://snapchat.com/NeutronCreative", 15 | "https://youtube.com/NeutronCreative", 16 | "asdasdasda", 17 | "asdasddas.com/asdasd", 18 | ] 19 | 20 | 21 | test("invalid user agents", () => { 22 | let agents = [ 23 | "asdasdasd", 24 | "", 25 | "1234512", 26 | "!*()*DJJ!8812jd*J)#*((", 27 | ] 28 | 29 | for (let agent of agents) { 30 | for (let url of testData) { 31 | let deepLink = DeepLinker.parseDeepLink(url, agent); 32 | let parser = new UAParser(agent); 33 | let os = parser.getOS().name; 34 | 35 | switch (os) { 36 | case "Android": 37 | expect(deepLink).toBe(DeepLinkGenerator.createAndroidDeepLink(deepLink)); 38 | break; 39 | case "iOS": 40 | expect(deepLink).toBe(DeepLinkGenerator.createiOSDeepLink(deepLink)); 41 | break; 42 | default: 43 | expect(deepLink).toBe(url); 44 | break; 45 | } 46 | } 47 | } 48 | 49 | }); 50 | 51 | 52 | test("test chrome useragents", () => { 53 | let agents = [ 54 | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36", 55 | "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36", 56 | "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36", 57 | "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36", 58 | "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36", 59 | "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/85.0.4183.92 Mobile/15E148 Safari/604.1", 60 | "Mozilla/5.0 (iPad; CPU OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/85.0.4183.92 Mobile/15E148 Safari/604.1", 61 | "Mozilla/5.0 (iPod; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/85.0.4183.92 Mobile/15E148 Safari/604.1", 62 | "Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36", 63 | "Mozilla/5.0 (Linux; Android 10; SM-A205U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36", 64 | "Mozilla/5.0 (Linux; Android 10; SM-A102U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36", 65 | "Mozilla/5.0 (Linux; Android 10; SM-G960U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36", 66 | "Mozilla/5.0 (Linux; Android 10; SM-N960U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36", 67 | "Mozilla/5.0 (Linux; Android 10; LM-Q720) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36", 68 | "Mozilla/5.0 (Linux; Android 10; LM-X420) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36", 69 | "Mozilla/5.0 (Linux; Android 10; LM-Q710(FGN)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36" 70 | ] 71 | 72 | for (let agent of agents) { 73 | for (let url of testData) { 74 | let deepLink = DeepLinker.parseDeepLink(url, agent); 75 | let parser = new UAParser(agent); 76 | let os = parser.getOS().name; 77 | 78 | switch (os) { 79 | case "Android": 80 | expect(deepLink).toBe(DeepLinkGenerator.createAndroidDeepLink(deepLink)); 81 | break; 82 | case "iOS": 83 | expect(deepLink).toBe(DeepLinkGenerator.createiOSDeepLink(deepLink)); 84 | break; 85 | default: 86 | expect(deepLink).toBe(url); 87 | break; 88 | } 89 | } 90 | } 91 | 92 | }); 93 | 94 | test("test firefox useragents", () => { 95 | let agents = [ 96 | "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0", 97 | "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:81.0) Gecko/20100101 Firefox/81.0", 98 | "Mozilla/5.0 (X11; Linux i686; rv:81.0) Gecko/20100101 Firefox/81.0", 99 | "Mozilla/5.0 (Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0", 100 | "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0", 101 | "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0", 102 | "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0", 103 | "Mozilla/5.0 (iPhone; CPU iPhone OS 10_15_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/28.0 Mobile/15E148 Safari/605.1.15", 104 | "Mozilla/5.0 (iPad; CPU OS 10_15_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/28.0 Mobile/15E148 Safari/605.1.15", 105 | "Mozilla/5.0 (iPod touch; CPU iPhone OS 10_15_7 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) FxiOS/28.0 Mobile/15E148 Safari/605.1.15", 106 | "Mozilla/5.0 (Android 11; Mobile; rv:68.0) Gecko/68.0 Firefox/81.0", 107 | "Mozilla/5.0 (Android 11; Mobile; LG-M255; rv:81.0) Gecko/81.0 Firefox/81.0", 108 | "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0", 109 | "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0", 110 | "Mozilla/5.0 (X11; Linux i686; rv:78.0) Gecko/20100101 Firefox/78.0", 111 | "Mozilla/5.0 (Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0", 112 | "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:78.0) Gecko/20100101 Firefox/78.0", 113 | "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0", 114 | "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" 115 | ] 116 | 117 | for (let agent of agents) { 118 | for (let url of testData) { 119 | let deepLink = DeepLinker.parseDeepLink(url, agent); 120 | let parser = new UAParser(agent); 121 | let os = parser.getOS().name; 122 | 123 | switch (os) { 124 | case "Android": 125 | expect(deepLink).toBe(DeepLinkGenerator.createAndroidDeepLink(deepLink)); 126 | break; 127 | case "iOS": 128 | expect(deepLink).toBe(DeepLinkGenerator.createiOSDeepLink(deepLink)); 129 | break; 130 | default: 131 | expect(deepLink).toBe(url); 132 | break; 133 | } 134 | } 135 | } 136 | 137 | }); 138 | 139 | test("test safari useragents", () => { 140 | let agents = [ 141 | "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36", 142 | "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/85.0.4183.92 Mobile/15E148 Safari/604.1", 143 | "Mozilla/5.0 (iPad; CPU OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/85.0.4183.92 Mobile/15E148 Safari/604.1", 144 | "Mozilla/5.0 (iPod; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/85.0.4183.92 Mobile/15E148 Safari/604.1" 145 | ] 146 | 147 | for (let agent of agents) { 148 | for (let url of testData) { 149 | let deepLink = DeepLinker.parseDeepLink(url, agent); 150 | let parser = new UAParser(agent); 151 | let os = parser.getOS().name; 152 | 153 | switch (os) { 154 | case "Android": 155 | expect(deepLink).toBe(DeepLinkGenerator.createAndroidDeepLink(deepLink)); 156 | break; 157 | case "iOS": 158 | expect(deepLink).toBe(DeepLinkGenerator.createiOSDeepLink(deepLink)); 159 | break; 160 | default: 161 | expect(deepLink).toBe(url); 162 | break; 163 | } 164 | } 165 | } 166 | 167 | }); 168 | 169 | test("test internet explorer useragents", () => { 170 | let agents = [ 171 | "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)", 172 | "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; Trident/4.0;)", 173 | "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)", 174 | "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.0)", 175 | "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)", 176 | "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)", 177 | "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2)", 178 | "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko", 179 | "Mozilla/5.0 (Windows NT 6.2; Trident/7.0; rv:11.0) like Gecko", 180 | "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko", 181 | "Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko" 182 | ] 183 | 184 | for (let agent of agents) { 185 | for (let url of testData) { 186 | let deepLink = DeepLinker.parseDeepLink(url, agent); 187 | let parser = new UAParser(agent); 188 | let os = parser.getOS().name; 189 | 190 | switch (os) { 191 | case "Android": 192 | expect(deepLink).toBe(DeepLinkGenerator.createAndroidDeepLink(deepLink)); 193 | break; 194 | case "iOS": 195 | expect(deepLink).toBe(DeepLinkGenerator.createiOSDeepLink(deepLink)); 196 | break; 197 | default: 198 | expect(deepLink).toBe(url); 199 | break; 200 | } 201 | } 202 | } 203 | 204 | }); 205 | 206 | test("test edge useragents", () => { 207 | let agents = [ 208 | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 Edg/85.0.564.51", 209 | "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 Edg/85.0.564.51", 210 | "Mozilla/5.0 (Linux; Android 10; HD1913) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36 EdgA/45.7.4.5059", 211 | "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36 EdgA/45.7.4.5059", 212 | "Mozilla/5.0 (Linux; Android 10; Pixel 3 XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36 EdgA/45.7.4.5059", 213 | "Mozilla/5.0 (Linux; Android 10; ONEPLUS A6003) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36 EdgA/45.7.4.5059", 214 | "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 EdgiOS/45.8.10 Mobile/15E148 Safari/605.1.15", 215 | "Mozilla/5.0 (Windows Mobile 10; Android 10.0; Microsoft; Lumia 950XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Mobile Safari/537.36 Edge/40.15254.603", 216 | "Mozilla/5.0 (Windows NT 10.0; Win64; x64; Xbox; Xbox One) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 Edge/44.18363.8131" 217 | ] 218 | 219 | for (let agent of agents) { 220 | for (let url of testData) { 221 | let deepLink = DeepLinker.parseDeepLink(url, agent); 222 | let parser = new UAParser(agent); 223 | let os = parser.getOS().name; 224 | 225 | switch (os) { 226 | case "Android": 227 | expect(deepLink).toBe(DeepLinkGenerator.createAndroidDeepLink(deepLink)); 228 | break; 229 | case "iOS": 230 | expect(deepLink).toBe(DeepLinkGenerator.createiOSDeepLink(deepLink)); 231 | break; 232 | default: 233 | expect(deepLink).toBe(url); 234 | break; 235 | } 236 | } 237 | } 238 | 239 | }); 240 | 241 | test("test opera useragents", () => { 242 | let agents = [ 243 | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 OPR/71.0.3770.148", 244 | "Mozilla/5.0 (Windows NT 10.0; WOW64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 OPR/71.0.3770.148", 245 | "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 OPR/71.0.3770.148", 246 | "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 OPR/71.0.3770.148", 247 | "Mozilla/5.0 (Linux; Android 10; VOG-L29) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36 OPR/59.1.2926.54067", 248 | "Mozilla/5.0 (Linux; Android 10; SM-G970F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36 OPR/59.1.2926.54067", 249 | "Mozilla/5.0 (Linux; Android 10; SM-N975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36 OPR/59.1.2926.54067" 250 | ] 251 | 252 | for (let agent of agents) { 253 | for (let url of testData) { 254 | let deepLink = DeepLinker.parseDeepLink(url, agent); 255 | let parser = new UAParser(agent); 256 | let os = parser.getOS().name; 257 | 258 | switch (os) { 259 | case "Android": 260 | expect(deepLink).toBe(DeepLinkGenerator.createAndroidDeepLink(deepLink)); 261 | break; 262 | case "iOS": 263 | expect(deepLink).toBe(DeepLinkGenerator.createiOSDeepLink(deepLink)); 264 | break; 265 | default: 266 | expect(deepLink).toBe(url); 267 | break; 268 | } 269 | } 270 | } 271 | 272 | }); 273 | 274 | test("test vivaldi useragents", () => { 275 | let agents = [ 276 | "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 Vivaldi/3.3", 277 | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 Vivaldi/3.3", 278 | "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 Vivaldi/3.3", 279 | "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 Vivaldi/3.3", 280 | "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 Vivaldi/3.3" 281 | ] 282 | 283 | for (let agent of agents) { 284 | for (let url of testData) { 285 | let deepLink = DeepLinker.parseDeepLink(url, agent); 286 | let parser = new UAParser(agent); 287 | let os = parser.getOS().name; 288 | 289 | switch (os) { 290 | case "Android": 291 | expect(deepLink).toBe(DeepLinkGenerator.createAndroidDeepLink(deepLink)); 292 | break; 293 | case "iOS": 294 | expect(deepLink).toBe(DeepLinkGenerator.createiOSDeepLink(deepLink)); 295 | break; 296 | default: 297 | expect(deepLink).toBe(url); 298 | break; 299 | } 300 | } 301 | } 302 | 303 | }); 304 | 305 | test("test yandex useragents", () => { 306 | let agents = [ 307 | "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 YaBrowser/20.8.0 Yowser/2.5 Safari/537.36", 308 | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 YaBrowser/20.8.0 Yowser/2.5 Safari/537.36", 309 | "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 YaBrowser/20.8.0 Yowser/2.5 Safari/537.36", 310 | "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 YaBrowser/20.8.2.271 Mobile/15E148 Safari/604.1", 311 | "Mozilla/5.0 (iPad; CPU OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 YaBrowser/20.8.2.271 Mobile/15E148 Safari/605.1", 312 | "Mozilla/5.0 (iPod touch; CPU iPhone 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 YaBrowser/20.8.2.271 Mobile/15E148 Safari/605.1", 313 | "Mozilla/5.0 (Linux; arm_64; Android 11; SM-G965F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 YaBrowser/20.6.3.54 Mobile Safari/537.36" 314 | ] 315 | 316 | for (let agent of agents) { 317 | for (let url of testData) { 318 | let deepLink = DeepLinker.parseDeepLink(url, agent); 319 | let parser = new UAParser(agent); 320 | let os = parser.getOS().name; 321 | 322 | switch (os) { 323 | case "Android": 324 | expect(deepLink).toBe(DeepLinkGenerator.createAndroidDeepLink(deepLink)); 325 | break; 326 | case "iOS": 327 | expect(deepLink).toBe(DeepLinkGenerator.createiOSDeepLink(deepLink)); 328 | break; 329 | default: 330 | expect(deepLink).toBe(url); 331 | break; 332 | } 333 | } 334 | } 335 | 336 | }); -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "target": "es2020", 5 | "module": "commonjs", 6 | "lib": [ 7 | "es2020", 8 | "es2017", 9 | "es7", 10 | "es6", 11 | "dom" 12 | ], 13 | "declaration": true, 14 | "outDir": "lib", 15 | "removeComments": false, 16 | "strict": true, 17 | "skipLibCheck": true, 18 | "strictNullChecks": true, 19 | "noImplicitThis": true, 20 | "inlineSourceMap": true, 21 | "inlineSources": true, 22 | "resolveJsonModule": true, 23 | "esModuleInterop": true, 24 | "allowJs": false 25 | }, 26 | "include": [ 27 | "src" 28 | ] 29 | } 30 | --------------------------------------------------------------------------------