├── .flowconfig ├── .github ├── dependabot.yml └── workflows │ ├── codeql.yml │ └── node.js.yml ├── .gitignore ├── .husky └── pre-commit ├── .mergify.yml ├── .nvmrc ├── .travis.yml ├── LICENSE ├── README.md ├── netlify.toml ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo192apple.png ├── logo512.png ├── logo512apple.png ├── manifest.json └── robots.txt ├── resources └── favicon │ ├── Links 16.pxd │ ├── QuickLook │ │ ├── Icon.tiff │ │ └── Thumbnail.tiff │ ├── data │ │ └── C366B15D-4F62-4C2B-96CD-AF105682A8FB │ └── metadata.info │ ├── Links 192 Apple.pxd │ ├── QuickLook │ │ ├── Icon.tiff │ │ └── Thumbnail.tiff │ ├── data │ │ └── C366B15D-4F62-4C2B-96CD-AF105682A8FB │ └── metadata.info │ ├── Links 192.pxd │ ├── QuickLook │ │ ├── Icon.tiff │ │ └── Thumbnail.tiff │ ├── data │ │ └── C366B15D-4F62-4C2B-96CD-AF105682A8FB │ └── metadata.info │ ├── Links 24.pxd │ ├── QuickLook │ │ ├── Icon.tiff │ │ └── Thumbnail.tiff │ ├── data │ │ └── C366B15D-4F62-4C2B-96CD-AF105682A8FB │ └── metadata.info │ ├── Links 32.pxd │ ├── QuickLook │ │ ├── Icon.tiff │ │ └── Thumbnail.tiff │ ├── data │ │ └── C366B15D-4F62-4C2B-96CD-AF105682A8FB │ └── metadata.info │ ├── Links 512 Apple.pxd │ ├── QuickLook │ │ ├── Icon.tiff │ │ └── Thumbnail.tiff │ ├── data │ │ └── C366B15D-4F62-4C2B-96CD-AF105682A8FB │ └── metadata.info │ ├── Links 512.pxd │ ├── QuickLook │ │ ├── Icon.tiff │ │ └── Thumbnail.tiff │ ├── data │ │ └── C366B15D-4F62-4C2B-96CD-AF105682A8FB │ └── metadata.info │ └── Links 64.pxd │ ├── QuickLook │ ├── Icon.tiff │ └── Thumbnail.tiff │ ├── data │ └── C366B15D-4F62-4C2B-96CD-AF105682A8FB │ └── metadata.info ├── src ├── API.js ├── Analytics.js ├── App.css ├── App.js ├── App.test.js ├── ServiceWorkerContext.js ├── ServiceWorkerStatus.js ├── index.css ├── index.js └── serviceWorker.js └── yarn.lock /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | /node_modules/resolve/test/resolver/malformed_package_json/ 3 | /node_modules/eslint-plugin-react/node_modules/resolve/test/resolver/malformed_package_json/ 4 | 5 | [include] 6 | 7 | [libs] 8 | 9 | [lints] 10 | 11 | [options] 12 | 13 | [strict] 14 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | registries: 3 | npm-npmjs: 4 | type: npm-registry 5 | url: https://registry.npmjs.org 6 | token: '${{secrets.NPM_TOKEN}}' 7 | npm-registry-npm-pkg-github-com-catchen: 8 | type: npm-registry 9 | url: https://npm.pkg.github.com/CatChen 10 | token: '${{secrets.NPM_GITHUB_TOKEN}}' 11 | 12 | updates: 13 | - package-ecosystem: npm 14 | directory: '/' 15 | schedule: 16 | interval: daily 17 | time: '03:00' 18 | timezone: US/Pacific 19 | reviewers: 20 | - catchen 21 | assignees: 22 | - catchen 23 | registries: 24 | - npm-npmjs 25 | - npm-registry-npm-pkg-github-com-catchen 26 | open-pull-requests-limit: 10 27 | 28 | - package-ecosystem: 'github-actions' 29 | directory: '/' 30 | schedule: 31 | interval: daily 32 | time: '03:00' 33 | timezone: US/Pacific 34 | reviewers: 35 | - catchen 36 | assignees: 37 | - catchen 38 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | schedule: 9 | - cron: "12 4 * * 0" 10 | 11 | jobs: 12 | analyze: 13 | name: Analyze 14 | runs-on: ubuntu-latest 15 | permissions: 16 | actions: read 17 | contents: read 18 | security-events: write 19 | 20 | strategy: 21 | fail-fast: false 22 | matrix: 23 | language: [ javascript ] 24 | 25 | steps: 26 | - name: Checkout 27 | uses: actions/checkout@v4 28 | 29 | - name: Initialize CodeQL 30 | uses: github/codeql-action/init@v3 31 | with: 32 | languages: ${{ matrix.language }} 33 | queries: +security-and-quality 34 | 35 | - name: Autobuild 36 | uses: github/codeql-action/autobuild@v3 37 | 38 | - name: Perform CodeQL Analysis 39 | uses: github/codeql-action/analyze@v3 40 | with: 41 | category: "/language:${{ matrix.language }}" 42 | -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [master] 9 | pull_request: 10 | branches: [master] 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | 16 | strategy: 17 | matrix: 18 | node-version: [14.x, 16.x] 19 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 20 | 21 | steps: 22 | - uses: actions/checkout@v4 23 | - name: Use Node.js ${{ matrix.node-version }} 24 | uses: actions/setup-node@v4 25 | with: 26 | node-version: ${{ matrix.node-version }} 27 | cache: 'yarn' 28 | - run: yarn install 29 | - run: yarn flow 30 | - run: yarn build 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | yarn pretty-quick --staged 5 | -------------------------------------------------------------------------------- /.mergify.yml: -------------------------------------------------------------------------------- 1 | pull_request_rules: 2 | - name: automatic merge for Dependabot pull requests 3 | conditions: 4 | - author=dependabot[bot] 5 | - status-success=build (16.x) 6 | - status-success=netlify/traceurl/deploy-preview 7 | - status-success=security/gitguardian 8 | actions: 9 | merge: 10 | method: squash 11 | delete_head_branch: 12 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 16 -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | install: 3 | - yarn install 4 | node_js: 5 | - stable 6 | cache: 7 | yarn: true 8 | directories: 9 | - node_modules 10 | script: 11 | - yarn build 12 | - yarn flow 13 | - yarn test 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Cat Chen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Trace URL [![Netlify Status](https://api.netlify.com/api/v1/badges/5a1b5f50-4cab-49de-829f-f410a513f1f0/deploy-status)](https://app.netlify.com/sites/traceurl/deploys) 2 | 3 | Trace URL helps you expand shortened URL into original URL or trace any URL with redirections towards the destination. If you want to use it without deploying the code, you can visit [https://traceurl.catchen.app/](https://traceurl.catchen.app/). 4 | 5 | ## Source Code Repositories 6 | 7 | This repository contains the code for the web user interface. [traceurl-api](https://github.com/CatChen/traceurl-api/) contains the code for the web API and it's deployed on Heroku. [traceurl](https://github.com/CatChen/traceurl/) is the library used in the API to follow URL redirections. 8 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [[redirects]] 2 | from = "https://traceurl.netlify.com/*" 3 | to = "https://traceurl.catchen.app/:splat" 4 | status = 301 5 | force = true 6 | 7 | [[headers]] 8 | for = "/*" 9 | [headers.values] 10 | X-Frame-Options = "DENY" 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "traceurl-web", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@material-ui/core": "^4.12.4", 7 | "@material-ui/icons": "^4.11.3", 8 | "@material-ui/lab": "^4.0.0-alpha.61", 9 | "react": "^18.3.1", 10 | "react-dom": "^18.3.1", 11 | "react-scripts": "5.0.1", 12 | "typeface-roboto": "^1.1.13" 13 | }, 14 | "scripts": { 15 | "start": "react-scripts start", 16 | "build": "react-scripts build", 17 | "flow": "flow", 18 | "test": "react-scripts test", 19 | "eject": "react-scripts eject", 20 | "prepare": "husky install" 21 | }, 22 | "prettier": { 23 | "singleQuote": true, 24 | "trailingComma": "all", 25 | "arrowParens": "always" 26 | }, 27 | "eslintConfig": { 28 | "extends": "react-app" 29 | }, 30 | "browserslist": { 31 | "production": [ 32 | ">0.2%", 33 | "not dead", 34 | "not op_mini all" 35 | ], 36 | "development": [ 37 | "last 1 chrome version", 38 | "last 1 firefox version", 39 | "last 1 safari version" 40 | ] 41 | }, 42 | "devDependencies": { 43 | "flow-bin": "^0.188.1", 44 | "husky": "^8.0.3", 45 | "prettier": "3.5.3", 46 | "pretty-quick": "^4.0.0" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | 36 | 37 | 41 | Trace URL 42 | 51 | 52 | 53 | 54 |
55 | 65 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/public/logo192.png -------------------------------------------------------------------------------- /public/logo192apple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/public/logo192apple.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/public/logo512.png -------------------------------------------------------------------------------- /public/logo512apple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/public/logo512apple.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "Trace URL", 3 | "name": "Trace URL", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "share_target": { 22 | "action": "/", 23 | "method": "GET", 24 | "enctype": "application/x-www-form-urlencoded", 25 | "params": { 26 | "title": "title", 27 | "text": "text", 28 | "url": "url" 29 | } 30 | }, 31 | "start_url": ".", 32 | "display": "standalone", 33 | "scope": "/", 34 | "theme_color": "#fafafa", 35 | "background_color": "#fafafa" 36 | } 37 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | -------------------------------------------------------------------------------- /resources/favicon/Links 16.pxd/QuickLook/Icon.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 16.pxd/QuickLook/Icon.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 16.pxd/QuickLook/Thumbnail.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 16.pxd/QuickLook/Thumbnail.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 16.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 16.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB -------------------------------------------------------------------------------- /resources/favicon/Links 16.pxd/metadata.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 16.pxd/metadata.info -------------------------------------------------------------------------------- /resources/favicon/Links 192 Apple.pxd/QuickLook/Icon.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 192 Apple.pxd/QuickLook/Icon.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 192 Apple.pxd/QuickLook/Thumbnail.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 192 Apple.pxd/QuickLook/Thumbnail.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 192 Apple.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 192 Apple.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB -------------------------------------------------------------------------------- /resources/favicon/Links 192 Apple.pxd/metadata.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 192 Apple.pxd/metadata.info -------------------------------------------------------------------------------- /resources/favicon/Links 192.pxd/QuickLook/Icon.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 192.pxd/QuickLook/Icon.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 192.pxd/QuickLook/Thumbnail.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 192.pxd/QuickLook/Thumbnail.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 192.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 192.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB -------------------------------------------------------------------------------- /resources/favicon/Links 192.pxd/metadata.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 192.pxd/metadata.info -------------------------------------------------------------------------------- /resources/favicon/Links 24.pxd/QuickLook/Icon.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 24.pxd/QuickLook/Icon.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 24.pxd/QuickLook/Thumbnail.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 24.pxd/QuickLook/Thumbnail.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 24.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 24.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB -------------------------------------------------------------------------------- /resources/favicon/Links 24.pxd/metadata.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 24.pxd/metadata.info -------------------------------------------------------------------------------- /resources/favicon/Links 32.pxd/QuickLook/Icon.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 32.pxd/QuickLook/Icon.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 32.pxd/QuickLook/Thumbnail.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 32.pxd/QuickLook/Thumbnail.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 32.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 32.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB -------------------------------------------------------------------------------- /resources/favicon/Links 32.pxd/metadata.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 32.pxd/metadata.info -------------------------------------------------------------------------------- /resources/favicon/Links 512 Apple.pxd/QuickLook/Icon.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 512 Apple.pxd/QuickLook/Icon.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 512 Apple.pxd/QuickLook/Thumbnail.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 512 Apple.pxd/QuickLook/Thumbnail.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 512 Apple.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 512 Apple.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB -------------------------------------------------------------------------------- /resources/favicon/Links 512 Apple.pxd/metadata.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 512 Apple.pxd/metadata.info -------------------------------------------------------------------------------- /resources/favicon/Links 512.pxd/QuickLook/Icon.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 512.pxd/QuickLook/Icon.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 512.pxd/QuickLook/Thumbnail.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 512.pxd/QuickLook/Thumbnail.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 512.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 512.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB -------------------------------------------------------------------------------- /resources/favicon/Links 512.pxd/metadata.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 512.pxd/metadata.info -------------------------------------------------------------------------------- /resources/favicon/Links 64.pxd/QuickLook/Icon.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 64.pxd/QuickLook/Icon.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 64.pxd/QuickLook/Thumbnail.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 64.pxd/QuickLook/Thumbnail.tiff -------------------------------------------------------------------------------- /resources/favicon/Links 64.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 64.pxd/data/C366B15D-4F62-4C2B-96CD-AF105682A8FB -------------------------------------------------------------------------------- /resources/favicon/Links 64.pxd/metadata.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/resources/favicon/Links 64.pxd/metadata.info -------------------------------------------------------------------------------- /src/API.js: -------------------------------------------------------------------------------- 1 | // @flow strict 2 | 3 | const PRODUCTION_ORIGIN = 'https://traceurl.herokuapp.com'; 4 | const DEVELOPMENT_ORIGIN = 5 | process.env.REACT_APP_API_ORIGIN || `http://${window.location.hostname}:4000`; 6 | const RESOLVE_ENDPOINT = '/resolve.json'; 7 | 8 | const origin = 9 | process.env.NODE_ENV === 'production' 10 | ? PRODUCTION_ORIGIN 11 | : DEVELOPMENT_ORIGIN; 12 | 13 | const API: { RESOLVE_ENDPOINT: string } = {}; 14 | Object.defineProperties(API, { 15 | RESOLVE_ENDPOINT: { 16 | value: origin + RESOLVE_ENDPOINT, 17 | configurable: false, 18 | enumerable: true, 19 | writable: false, 20 | }, 21 | }); 22 | 23 | export default API; 24 | -------------------------------------------------------------------------------- /src/Analytics.js: -------------------------------------------------------------------------------- 1 | // @flow strict 2 | 3 | if (!window.gtag) { 4 | window.dataLayer = window.dataLayer || []; 5 | window.gtag = function(...args) { 6 | window.dataLayer.push(arguments); 7 | }; 8 | } 9 | 10 | const Analytics = { 11 | logEvent: ( 12 | category: string, 13 | action: string, 14 | label?: ?string, 15 | value?: ?number, 16 | interaction?: boolean = true, 17 | ): void => { 18 | window.gtag('event', action, { 19 | non_interaction: !interaction, 20 | event_category: category, 21 | event_label: label, 22 | value: value, 23 | }); 24 | }, 25 | }; 26 | 27 | export default Analytics; 28 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CatChen/traceurl-web/95fc93c643212f0dc1e28202547c7c66ac877377/src/App.css -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | // @flow strict 2 | 3 | import React, { useEffect, useRef, useState } from 'react'; 4 | import './App.css'; 5 | import { 6 | Box, 7 | Button, 8 | Card, 9 | CardActions, 10 | CardContent, 11 | Container, 12 | CssBaseline, 13 | Link, 14 | TextField, 15 | Typography, 16 | } from '@material-ui/core'; 17 | import FileCopy from '@material-ui/icons/FileCopyOutlined'; 18 | import ShareNew from '@material-ui/icons/ShareOutlined'; 19 | import OpenInNew from '@material-ui/icons/OpenInNewOutlined'; 20 | import Refresh from '@material-ui/icons/RefreshOutlined'; 21 | import Skeleton from '@material-ui/lab/Skeleton'; 22 | import Analytics from './Analytics'; 23 | import API from './API'; 24 | import ServiceWorkerStatus from './ServiceWorkerStatus'; 25 | 26 | type NetworkState = 'none' | 'working' | 'success' | 'failure'; 27 | type Destination = {| url: string |}; 28 | type Hops = {| urls: Array |}; 29 | type Resolution = Destination | Hops; 30 | 31 | function extractURL(): string { 32 | const locationURL = new URL(window.location.href); 33 | const urlParam = locationURL.searchParams.get('url'); 34 | const textParam = locationURL.searchParams.get('text'); 35 | let maybeURL = ''; 36 | if (urlParam) { 37 | try { 38 | new URL(urlParam); 39 | maybeURL = urlParam; 40 | } catch {} 41 | } 42 | if (maybeURL === '' && textParam) { 43 | try { 44 | new URL(textParam); 45 | maybeURL = textParam; 46 | } catch {} 47 | } 48 | return maybeURL; 49 | } 50 | 51 | function App(): React$Element<'div'> { 52 | const [network, setNetwork] = useState('none'); 53 | const [url, setURL] = useState(extractURL()); 54 | const [resolution, setResolution] = useState(null); 55 | const [requestID, setRequestID] = useState(''); 56 | 57 | useEffect(() => { 58 | Analytics.logEvent('app', 'mount'); 59 | 60 | const handler = (event) => { 61 | Analytics.logEvent('history', 'popstate'); 62 | 63 | setURL(extractURL()); 64 | if (event.state) { 65 | setRequestID(event.state.requestID); 66 | setResolution(event.state.resolution); 67 | } else { 68 | // null state of the full page load 69 | setRequestID(''); 70 | setResolution(null); 71 | } 72 | }; 73 | window.addEventListener('popstate', handler); 74 | 75 | const initialURL = extractURL(); 76 | if (initialURL !== '') { 77 | trace(initialURL); // no await -- fire and forget 78 | } 79 | return () => { 80 | window.removeEventListener('popstate', handler); 81 | 82 | Analytics.logEvent('app', 'unmount'); 83 | }; 84 | }, []); 85 | 86 | const requestIDElement = useRef(null); 87 | 88 | const trace = async (url: string): Promise => { 89 | Analytics.logEvent('trace', 'start', url, undefined, false); 90 | 91 | const thisRequestID = Math.floor(Math.random() * Math.pow(36, 8)).toString( 92 | 36, 93 | ); 94 | 95 | setNetwork('working'); 96 | setRequestID(thisRequestID); 97 | window.history.replaceState({ requestID: thisRequestID }, document.title); 98 | 99 | try { 100 | const api = new URL(API.RESOLVE_ENDPOINT); 101 | api.searchParams.append('url', url); 102 | 103 | const response = await fetch(api); 104 | const resolution = await response.json(); 105 | 106 | if ( 107 | requestIDElement.current && 108 | requestIDElement.current.value === thisRequestID 109 | ) { 110 | // discord response if it's not for the current request 111 | setResolution(resolution); 112 | setNetwork('success'); 113 | window.history.replaceState( 114 | { requestID: thisRequestID, resolution }, 115 | document.title, 116 | ); 117 | 118 | Analytics.logEvent('trace', 'succeed', url, 1, false); 119 | } 120 | } catch { 121 | setNetwork('failure'); 122 | 123 | Analytics.logEvent('trace', 'fail', url, undefined, false); 124 | } 125 | }; 126 | 127 | let result; 128 | switch (network) { 129 | case 'working': 130 | result = ( 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 146 | 149 | 150 | 151 | ); 152 | break; 153 | case 'success': 154 | if (resolution) { 155 | if (typeof resolution.url === 'string') { 156 | const resolutionURL = resolution.url; 157 | result = ( 158 | 159 | 160 | 161 | Result 162 | 163 | 167 | {resolutionURL} 168 | 169 | 170 | 171 | 195 | {'share' in navigator ? ( 196 | 212 | ) : null} 213 | 227 | 228 | 229 | ); 230 | } else { 231 | } 232 | } 233 | break; 234 | case 'failure': 235 | result = ( 236 | 237 | 238 | 239 | Failure 240 | 241 | 242 | 243 | 256 | 257 | 258 | ); 259 | break; 260 | case 'none': 261 | default: 262 | result = null; 263 | break; 264 | } 265 | 266 | return ( 267 |
268 | 269 | 270 | 271 | 272 | Trace URL 273 | 274 | 275 | 276 | This tool helps you expand shortened URL into original URL or trace 277 | any URL with redirections towards the destination. It's{' '} 278 | 279 | open source 280 | 281 | . 282 | 283 |
{ 285 | Analytics.logEvent('form', 'submit'); 286 | 287 | event.preventDefault(); 288 | 289 | const navigationURL = new URL(window.location.href); 290 | navigationURL.searchParams.delete('url'); 291 | 292 | try { 293 | new URL(url); 294 | } catch { 295 | // empty or invalid URL 296 | setNetwork('none'); 297 | window.history.pushState( 298 | {}, 299 | document.title, 300 | navigationURL.toString(), 301 | ); 302 | return; 303 | } 304 | 305 | navigationURL.searchParams.append('url', url); 306 | window.history.pushState( 307 | {}, 308 | document.title, 309 | navigationURL.toString(), 310 | ); 311 | 312 | await trace(url); 313 | }} 314 | > 315 | 316 | { 330 | setURL(event.target.value); 331 | }} 332 | /> 333 | 341 | 342 | {result} 343 | 344 |
345 |
346 | ); 347 | } 348 | 349 | export default App; 350 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /src/ServiceWorkerContext.js: -------------------------------------------------------------------------------- 1 | // @flow strict 2 | 3 | import React, { 4 | createContext, 5 | useContext, 6 | useEffect, 7 | useMemo, 8 | useState, 9 | } from 'react'; 10 | import type { AbstractComponent } from 'react'; 11 | import Analytics from './Analytics'; 12 | 13 | type ServiceWorkerContextValue = {| 14 | updateAvailable: boolean, 15 | cacheComplete: boolean, 16 | applyUpdate: () => void, 17 | |}; 18 | 19 | const ServiceWorkerContext = createContext({ 20 | updateAvailable: false, 21 | cacheComplete: false, 22 | applyUpdate: () => {}, 23 | }); 24 | 25 | export function withServiceWorkerContextProvider( 26 | Component: AbstractComponent, 27 | ): AbstractComponent { 28 | return (props: Config) => { 29 | const [updateAvailable, setUpdateAvailable] = useState(false); 30 | const [cacheComplete, setCacheComplete] = useState(false); 31 | const [ 32 | registration, 33 | setRegistration, 34 | ] = useState(null); 35 | 36 | const value = useMemo(() => { 37 | return { 38 | updateAvailable, 39 | cacheComplete, 40 | applyUpdate: () => { 41 | Analytics.logEvent( 42 | 'service_worker_apply_update', 43 | 'start', 44 | undefined, 45 | undefined, 46 | false, 47 | ); 48 | 49 | if (!registration || !registration.waiting) { 50 | Analytics.logEvent( 51 | 'service_worker_apply_update', 52 | 'failure', 53 | undefined, 54 | undefined, 55 | false, 56 | ); 57 | 58 | return; 59 | } 60 | const waitingServiceWorker = registration.waiting; 61 | waitingServiceWorker.addEventListener('statechange', () => { 62 | if (waitingServiceWorker.state === 'activated') { 63 | Analytics.logEvent( 64 | 'service_worker_apply_update', 65 | 'success', 66 | undefined, 67 | undefined, 68 | false, 69 | ); 70 | 71 | window.location.reload(); 72 | } 73 | }); 74 | 75 | waitingServiceWorker.postMessage({ type: 'SKIP_WAITING' }); 76 | }, 77 | }; 78 | }, [updateAvailable, cacheComplete, registration]); 79 | 80 | useEffect(() => { 81 | if (window.updateAvailable) { 82 | window.updateAvailable.then((registration) => { 83 | console.log('service_worker', 'update_available'); 84 | Analytics.logEvent( 85 | 'service_worker', 86 | 'update_available', 87 | undefined, 88 | undefined, 89 | false, 90 | ); 91 | 92 | setUpdateAvailable(true); 93 | }); 94 | } 95 | 96 | if (window.cacheComplete) { 97 | window.cacheComplete.then((registration) => { 98 | console.log('service_worker', 'cache_complete'); 99 | Analytics.logEvent( 100 | 'service_worker', 101 | 'cache_complete', 102 | undefined, 103 | undefined, 104 | false, 105 | ); 106 | 107 | setCacheComplete(true); 108 | }); 109 | } 110 | 111 | (async () => { 112 | if (navigator.serviceWorker) { 113 | const serviceWorker = navigator.serviceWorker; 114 | const registration = await serviceWorker.getRegistration('/'); 115 | if (!registration) { 116 | return; 117 | } 118 | 119 | setRegistration(registration); 120 | 121 | if (registration.waiting) { 122 | console.log('service_worker', 'update_available'); 123 | Analytics.logEvent( 124 | 'service_worker', 125 | 'update_available', 126 | undefined, 127 | undefined, 128 | false, 129 | ); 130 | 131 | setUpdateAvailable(true); 132 | } 133 | } 134 | })(); 135 | }, []); 136 | 137 | return ( 138 | 139 | 140 | 141 | ); 142 | }; 143 | } 144 | 145 | export function useServiceWorkerContext(): ServiceWorkerContextValue { 146 | const context = useContext(ServiceWorkerContext); 147 | return context; 148 | } 149 | -------------------------------------------------------------------------------- /src/ServiceWorkerStatus.js: -------------------------------------------------------------------------------- 1 | // @flow strict 2 | 3 | import React, { useState } from 'react'; 4 | import { IconButton, Slide, Snackbar, Typography } from '@material-ui/core'; 5 | import Close from '@material-ui/icons/Close'; 6 | import SystemUpdate from '@material-ui/icons/SystemUpdateOutlined'; 7 | import Analytics from './Analytics'; 8 | import { 9 | withServiceWorkerContextProvider, 10 | useServiceWorkerContext, 11 | } from './ServiceWorkerContext'; 12 | 13 | import type { AbstractComponent, ElementConfig } from 'react'; 14 | 15 | function ServiceWorkerStatus() { 16 | return ( 17 | <> 18 | 19 | 20 | 21 | ); 22 | } 23 | 24 | function ServiceWorkerUpdateStatus() { 25 | const context = useServiceWorkerContext(); 26 | 27 | return ( 28 | App update available.} 33 | action={ 34 | { 37 | Analytics.logEvent('update', 'click'); 38 | 39 | context.applyUpdate(); 40 | }} 41 | > 42 | 43 | 44 | } 45 | /> 46 | ); 47 | } 48 | 49 | function ServiceWorkerCacheStatus() { 50 | const [dismissed, setDismissed] = useState(false); 51 | const context = useServiceWorkerContext(); 52 | 53 | const close = () => { 54 | setDismissed(true); 55 | }; 56 | 57 | return ( 58 | App available offline.} 64 | action={ 65 | { 68 | Analytics.logEvent('close', 'click'); 69 | 70 | close(); 71 | }} 72 | > 73 | 74 | 75 | } 76 | /> 77 | ); 78 | } 79 | 80 | export default (withServiceWorkerContextProvider< 81 | ElementConfig, 82 | >(ServiceWorkerStatus): AbstractComponent>); 83 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 4 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import Analytics from './Analytics'; 5 | import App from './App'; 6 | import * as serviceWorker from './serviceWorker'; 7 | import 'typeface-roboto'; 8 | 9 | window.addEventListener('beforeinstallprompt', async (event) => { 10 | const choiceResult = await event.userChoice(); 11 | Analytics.logEvent('app', 'prompt', choiceResult.outcome); 12 | }); 13 | 14 | window.addEventListener('appinstalled', (event) => { 15 | Analytics.logEvent('app', 'install', undefined, 1); 16 | }); 17 | 18 | let resolveUpdateAvailable; 19 | let resolveCacheComplete; 20 | window.updateAvailable = new Promise((resolve) => { 21 | resolveUpdateAvailable = resolve; 22 | }); 23 | window.cacheComplete = new Promise((resolve) => { 24 | resolveCacheComplete = resolve; 25 | }); 26 | 27 | ReactDOM.render(, document.getElementById('root')); 28 | 29 | // If you want your app to work offline and load faster, you can change 30 | // unregister() to register() below. Note this comes with some pitfalls. 31 | // Learn more about service workers: https://bit.ly/CRA-PWA 32 | serviceWorker.register({ 33 | onUpdate: (registration) => { 34 | resolveUpdateAvailable(registration); 35 | }, 36 | onSuccess: (registration) => { 37 | resolveCacheComplete(registration); 38 | }, 39 | }); 40 | -------------------------------------------------------------------------------- /src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.1/8 is considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/, 20 | ), 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener('load', () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | 'This web app is being served cache-first by a service ' + 46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA', 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then((registration) => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === 'installed') { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | 'New content is available and will be used when all ' + 74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.', 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log('Content is cached for offline use.'); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch((error) => { 97 | console.error('Error during service worker registration:', error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl) 104 | .then((response) => { 105 | // Ensure service worker exists, and that we really are getting a JS file. 106 | const contentType = response.headers.get('content-type'); 107 | if ( 108 | response.status === 404 || 109 | (contentType != null && contentType.indexOf('javascript') === -1) 110 | ) { 111 | // No service worker found. Probably a different app. Reload the page. 112 | navigator.serviceWorker.ready.then((registration) => { 113 | registration.unregister().then(() => { 114 | window.location.reload(); 115 | }); 116 | }); 117 | } else { 118 | // Service worker found. Proceed as normal. 119 | registerValidSW(swUrl, config); 120 | } 121 | }) 122 | .catch(() => { 123 | console.log( 124 | 'No internet connection found. App is running in offline mode.', 125 | ); 126 | }); 127 | } 128 | 129 | export function unregister() { 130 | if ('serviceWorker' in navigator) { 131 | navigator.serviceWorker.ready.then((registration) => { 132 | registration.unregister(); 133 | }); 134 | } 135 | } 136 | --------------------------------------------------------------------------------