diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index b6d5bdc..60c2913 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - node_version: [20.x, 22.x, 23.x] + node_version: [20.x, 22.x, 24.x] steps: - uses: actions/checkout@v4 @@ -24,8 +24,6 @@ jobs: - name: run npm scripts env: - FACEBOOK_APP_ID: ${{ secrets.FACEBOOK_APP_ID }} - FACEBOOK_CLIENT_TOKEN: ${{ secrets.FACEBOOK_CLIENT_TOKEN }} PROXY_SERVER: ${{ secrets.PROXY_SERVER }} run: | npm install @@ -33,13 +31,6 @@ jobs: npm run build --if-present npm run test - - name: Coveralls Parallel - uses: coverallsapp/github-action@v2 - with: - flag-name: run-${{ join(matrix.*, '-') }} - parallel: true - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: cache node modules uses: actions/cache@v4 with: @@ -47,15 +38,3 @@ jobs: key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- - - finish: - needs: test - if: ${{ always() }} - runs-on: ubuntu-latest - steps: - - name: Coveralls Finished - uses: coverallsapp/github-action@v2 - with: - parallel-finished: true - carryforward: "run-20.x,run-22.x,run-23.x" - diff --git a/README.md b/README.md index d9699d3..d92d3b8 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ Extract oEmbed content from given URL. [![NPM](https://badge.fury.io/js/@extractus%2Foembed-extractor.svg)](https://badge.fury.io/js/@extractus%2Foembed-extractor) ![CodeQL](https://github.com/extractus/oembed-extractor/workflows/CodeQL/badge.svg) [![CI test](https://github.com/extractus/oembed-extractor/workflows/ci-test/badge.svg)](https://github.com/extractus/oembed-extractor/actions) -[![Coverage Status](https://coveralls.io/repos/github/extractus/oembed-extractor/badge.svg)](https://coveralls.io/github/extractus/oembed-extractor) ## Demo @@ -45,9 +44,6 @@ import { extract } from 'npm:@extractus/oembed-extractor' import { extract } from "https://esm.sh/@extractus/oembed-extractor@latest" ``` -Please check [the examples](examples) for reference. - - ## APIs ### `.extract()` diff --git a/examples/browser-oembed-parser/.gitignore b/examples/browser-oembed-parser/.gitignore deleted file mode 100644 index 48012a9..0000000 --- a/examples/browser-oembed-parser/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -# Logs -logs -*.log -*.debug - -# Runtime data -*.pid -*.seed - -node_modules -coverage -.nyc_output - -.DS_Store -yarn.lock -coverage.lcov -pnpm-lock.yaml diff --git a/examples/browser-oembed-parser/README.md b/examples/browser-oembed-parser/README.md deleted file mode 100644 index 365e1d4..0000000 --- a/examples/browser-oembed-parser/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# browser-oembed-parser - -This demo shows how to use `oembed-extractor` at client side, with or without proxy. - -To install: - -```bash -npm i - -# or pnpm, yarn -``` - -Start server: - -```bash -npm start -``` - -Open `http://127.0.0.1:3101/` to test. - -Basically `oembed-extractor` only works at server side. - -However there are some noble providers those enable `Access-Control-Allow-Origin` on their service. -For example with oembed links from YouTube, TED or CodeSandbox, we can parse from browser. - -Another ideal environment to run `oembed-extractor` directly is browser extensions. - -With the remaining cases, we need a proxy layer to bypass CORS policy. - -![oembed-extractor on browser](https://res.cloudinary.com/pwshub/image/upload/v1663745151/documentation/oembed-parser-on-browser.png) - - ---- diff --git a/examples/browser-oembed-parser/package.json b/examples/browser-oembed-parser/package.json deleted file mode 100644 index d4844d7..0000000 --- a/examples/browser-oembed-parser/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "browser-oembed-parser", - "version": "1.0.0", - "type": "module", - "scripts": { - "start": "node server" - }, - "dependencies": { - "express": "latest", - "got": "latest" - } -} diff --git a/examples/browser-oembed-parser/public/chota.min.css b/examples/browser-oembed-parser/public/chota.min.css deleted file mode 100644 index b445236..0000000 --- a/examples/browser-oembed-parser/public/chota.min.css +++ /dev/null @@ -1 +0,0 @@ -/*! chota.css v0.7.2 | MIT License | github.com/jenil/chota */:root{--bg-color:#fff;--bg-secondary-color:#f3f3f6;--color-primary:#14854f;--color-lightGrey:#d2d6dd;--color-grey:#747681;--color-darkGrey:#3f4144;--color-error:#d43939;--color-success:#28bd14;--grid-maxWidth:120rem;--grid-gutter:2rem;--font-size:1.6rem;--font-color:#333;--font-family-sans:-apple-system,BlinkMacSystemFont,Avenir,"Avenir Next","Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;--font-family-mono:monaco,"Consolas","Lucida Console",monospace}html{-webkit-box-sizing:border-box;box-sizing:border-box;font-size:62.5%;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}*,:after,:before{-webkit-box-sizing:inherit;box-sizing:inherit}body{background-color:var(--bg-color);line-height:1.6;font-size:var(--font-size);color:var(--font-color);font-family:Segoe UI,Helvetica Neue,sans-serif;font-family:var(--font-family-sans);margin:0;padding:0}h1,h2,h3,h4,h5,h6{font-weight:500;margin:.35em 0 .7em}h1{font-size:2em}h2{font-size:1.75em}h3{font-size:1.5em}h4{font-size:1.25em}h5{font-size:1em}h6{font-size:.85em}a{color:var(--color-primary);text-decoration:none}a:hover:not(.button){opacity:.75}button{font-family:inherit}p{margin-top:0}blockquote{background-color:var(--bg-secondary-color);padding:1.5rem 2rem;border-left:3px solid var(--color-lightGrey)}dl dt{font-weight:700}hr{background-color:var(--color-lightGrey);height:1px;margin:1rem 0}hr,table{border:none}table{width:100%;border-collapse:collapse;border-spacing:0;text-align:left}table.striped tr:nth-of-type(2n){background-color:var(--bg-secondary-color)}td,th{vertical-align:middle;padding:1.2rem .4rem}thead{border-bottom:2px solid var(--color-lightGrey)}tfoot{border-top:2px solid var(--color-lightGrey)}code,kbd,pre,samp,tt{font-family:var(--font-family-mono)}code,kbd{font-size:90%;white-space:pre-wrap;border-radius:4px;padding:.2em .4em;color:var(--color-error)}code,kbd,pre{background-color:var(--bg-secondary-color)}pre{font-size:1em;padding:1rem;overflow-x:auto}pre code{background:none;padding:0}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}img{max-width:100%}fieldset{border:1px solid var(--color-lightGrey)}iframe{border:0}.container{max-width:var(--grid-maxWidth);margin:0 auto;width:96%;padding:0 calc(var(--grid-gutter)/2)}.row{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-direction:normal;-ms-flex-flow:row wrap;flex-flow:row wrap;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start;margin-left:calc(var(--grid-gutter)/-2);margin-right:calc(var(--grid-gutter)/-2)}.row,.row.reverse{-webkit-box-orient:horizontal}.row.reverse{-webkit-box-direction:reverse;-ms-flex-direction:row-reverse;flex-direction:row-reverse}.col{-webkit-box-flex:1;-ms-flex:1;flex:1}.col,[class*=" col-"],[class^=col-]{margin:0 calc(var(--grid-gutter)/2) calc(var(--grid-gutter)/2)}.col-1{-ms-flex:0 0 calc(8.33333% - var(--grid-gutter));flex:0 0 calc(8.33333% - var(--grid-gutter));max-width:calc(8.33333% - var(--grid-gutter))}.col-1,.col-2{-webkit-box-flex:0}.col-2{-ms-flex:0 0 calc(16.66667% - var(--grid-gutter));flex:0 0 calc(16.66667% - var(--grid-gutter));max-width:calc(16.66667% - var(--grid-gutter))}.col-3{-ms-flex:0 0 calc(25% - var(--grid-gutter));flex:0 0 calc(25% - var(--grid-gutter));max-width:calc(25% - var(--grid-gutter))}.col-3,.col-4{-webkit-box-flex:0}.col-4{-ms-flex:0 0 calc(33.33333% - var(--grid-gutter));flex:0 0 calc(33.33333% - var(--grid-gutter));max-width:calc(33.33333% - var(--grid-gutter))}.col-5{-ms-flex:0 0 calc(41.66667% - var(--grid-gutter));flex:0 0 calc(41.66667% - var(--grid-gutter));max-width:calc(41.66667% - var(--grid-gutter))}.col-5,.col-6{-webkit-box-flex:0}.col-6{-ms-flex:0 0 calc(50% - var(--grid-gutter));flex:0 0 calc(50% - var(--grid-gutter));max-width:calc(50% - var(--grid-gutter))}.col-7{-ms-flex:0 0 calc(58.33333% - var(--grid-gutter));flex:0 0 calc(58.33333% - var(--grid-gutter));max-width:calc(58.33333% - var(--grid-gutter))}.col-7,.col-8{-webkit-box-flex:0}.col-8{-ms-flex:0 0 calc(66.66667% - var(--grid-gutter));flex:0 0 calc(66.66667% - var(--grid-gutter));max-width:calc(66.66667% - var(--grid-gutter))}.col-9{-ms-flex:0 0 calc(75% - var(--grid-gutter));flex:0 0 calc(75% - var(--grid-gutter));max-width:calc(75% - var(--grid-gutter))}.col-9,.col-10{-webkit-box-flex:0}.col-10{-ms-flex:0 0 calc(83.33333% - var(--grid-gutter));flex:0 0 calc(83.33333% - var(--grid-gutter));max-width:calc(83.33333% - var(--grid-gutter))}.col-11{-ms-flex:0 0 calc(91.66667% - var(--grid-gutter));flex:0 0 calc(91.66667% - var(--grid-gutter));max-width:calc(91.66667% - var(--grid-gutter))}.col-11,.col-12{-webkit-box-flex:0}.col-12{-ms-flex:0 0 calc(100% - var(--grid-gutter));flex:0 0 calc(100% - var(--grid-gutter));max-width:calc(100% - var(--grid-gutter))}@media screen and (max-width:599px){.container{width:100%}.col,[class*=col-],[class^=col-]{-webkit-box-flex:0;-ms-flex:0 1 100%;flex:0 1 100%;max-width:100%}}@media screen and (min-width:900px){.col-1-md{-webkit-box-flex:0;-ms-flex:0 0 calc(8.33333% - var(--grid-gutter));flex:0 0 calc(8.33333% - var(--grid-gutter));max-width:calc(8.33333% - var(--grid-gutter))}.col-2-md{-webkit-box-flex:0;-ms-flex:0 0 calc(16.66667% - var(--grid-gutter));flex:0 0 calc(16.66667% - var(--grid-gutter));max-width:calc(16.66667% - var(--grid-gutter))}.col-3-md{-webkit-box-flex:0;-ms-flex:0 0 calc(25% - var(--grid-gutter));flex:0 0 calc(25% - var(--grid-gutter));max-width:calc(25% - var(--grid-gutter))}.col-4-md{-webkit-box-flex:0;-ms-flex:0 0 calc(33.33333% - var(--grid-gutter));flex:0 0 calc(33.33333% - var(--grid-gutter));max-width:calc(33.33333% - var(--grid-gutter))}.col-5-md{-webkit-box-flex:0;-ms-flex:0 0 calc(41.66667% - var(--grid-gutter));flex:0 0 calc(41.66667% - var(--grid-gutter));max-width:calc(41.66667% - var(--grid-gutter))}.col-6-md{-webkit-box-flex:0;-ms-flex:0 0 calc(50% - var(--grid-gutter));flex:0 0 calc(50% - var(--grid-gutter));max-width:calc(50% - var(--grid-gutter))}.col-7-md{-webkit-box-flex:0;-ms-flex:0 0 calc(58.33333% - var(--grid-gutter));flex:0 0 calc(58.33333% - var(--grid-gutter));max-width:calc(58.33333% - var(--grid-gutter))}.col-8-md{-webkit-box-flex:0;-ms-flex:0 0 calc(66.66667% - var(--grid-gutter));flex:0 0 calc(66.66667% - var(--grid-gutter));max-width:calc(66.66667% - var(--grid-gutter))}.col-9-md{-webkit-box-flex:0;-ms-flex:0 0 calc(75% - var(--grid-gutter));flex:0 0 calc(75% - var(--grid-gutter));max-width:calc(75% - var(--grid-gutter))}.col-10-md{-webkit-box-flex:0;-ms-flex:0 0 calc(83.33333% - var(--grid-gutter));flex:0 0 calc(83.33333% - var(--grid-gutter));max-width:calc(83.33333% - var(--grid-gutter))}.col-11-md{-webkit-box-flex:0;-ms-flex:0 0 calc(91.66667% - var(--grid-gutter));flex:0 0 calc(91.66667% - var(--grid-gutter));max-width:calc(91.66667% - var(--grid-gutter))}.col-12-md{-webkit-box-flex:0;-ms-flex:0 0 calc(100% - var(--grid-gutter));flex:0 0 calc(100% - var(--grid-gutter));max-width:calc(100% - var(--grid-gutter))}}@media screen and (min-width:1200px){.col-1-lg{-webkit-box-flex:0;-ms-flex:0 0 calc(8.33333% - var(--grid-gutter));flex:0 0 calc(8.33333% - var(--grid-gutter));max-width:calc(8.33333% - var(--grid-gutter))}.col-2-lg{-webkit-box-flex:0;-ms-flex:0 0 calc(16.66667% - var(--grid-gutter));flex:0 0 calc(16.66667% - var(--grid-gutter));max-width:calc(16.66667% - var(--grid-gutter))}.col-3-lg{-webkit-box-flex:0;-ms-flex:0 0 calc(25% - var(--grid-gutter));flex:0 0 calc(25% - var(--grid-gutter));max-width:calc(25% - var(--grid-gutter))}.col-4-lg{-webkit-box-flex:0;-ms-flex:0 0 calc(33.33333% - var(--grid-gutter));flex:0 0 calc(33.33333% - var(--grid-gutter));max-width:calc(33.33333% - var(--grid-gutter))}.col-5-lg{-webkit-box-flex:0;-ms-flex:0 0 calc(41.66667% - var(--grid-gutter));flex:0 0 calc(41.66667% - var(--grid-gutter));max-width:calc(41.66667% - var(--grid-gutter))}.col-6-lg{-webkit-box-flex:0;-ms-flex:0 0 calc(50% - var(--grid-gutter));flex:0 0 calc(50% - var(--grid-gutter));max-width:calc(50% - var(--grid-gutter))}.col-7-lg{-webkit-box-flex:0;-ms-flex:0 0 calc(58.33333% - var(--grid-gutter));flex:0 0 calc(58.33333% - var(--grid-gutter));max-width:calc(58.33333% - var(--grid-gutter))}.col-8-lg{-webkit-box-flex:0;-ms-flex:0 0 calc(66.66667% - var(--grid-gutter));flex:0 0 calc(66.66667% - var(--grid-gutter));max-width:calc(66.66667% - var(--grid-gutter))}.col-9-lg{-webkit-box-flex:0;-ms-flex:0 0 calc(75% - var(--grid-gutter));flex:0 0 calc(75% - var(--grid-gutter));max-width:calc(75% - var(--grid-gutter))}.col-10-lg{-webkit-box-flex:0;-ms-flex:0 0 calc(83.33333% - var(--grid-gutter));flex:0 0 calc(83.33333% - var(--grid-gutter));max-width:calc(83.33333% - var(--grid-gutter))}.col-11-lg{-webkit-box-flex:0;-ms-flex:0 0 calc(91.66667% - var(--grid-gutter));flex:0 0 calc(91.66667% - var(--grid-gutter));max-width:calc(91.66667% - var(--grid-gutter))}.col-12-lg{-webkit-box-flex:0;-ms-flex:0 0 calc(100% - var(--grid-gutter));flex:0 0 calc(100% - var(--grid-gutter));max-width:calc(100% - var(--grid-gutter))}}fieldset{padding:.5rem 2rem}legend{text-transform:uppercase;font-size:.8em;letter-spacing:.1rem}input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=color]):not([type=button]):not([type=reset]),select,textarea,textarea[type=text]{font-family:inherit;padding:.8rem 1rem;border-radius:4px;border:1px solid var(--color-lightGrey);font-size:1em;-webkit-transition:all .2s ease;transition:all .2s ease;display:block;width:100%}input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=color]):not([type=button]):not([type=reset]):not(:disabled):hover,select:hover,textarea:hover,textarea[type=text]:hover{border-color:var(--color-grey)}input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=color]):not([type=button]):not([type=reset]):focus,select:focus,textarea:focus,textarea[type=text]:focus{outline:none;border-color:var(--color-primary);-webkit-box-shadow:0 0 1px var(--color-primary);box-shadow:0 0 1px var(--color-primary)}input.error:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=color]):not([type=button]):not([type=reset]),textarea.error{border-color:var(--color-error)}input.success:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=color]):not([type=button]):not([type=reset]),textarea.success{border-color:var(--color-success)}select{-webkit-appearance:none;background:#f3f3f6 no-repeat 100%;background-size:1ex;background-origin:content-box;background-image:url("data:image/svg+xml;utf8,")}[type=checkbox],[type=radio]{width:1.6rem;height:1.6rem}.button,[type=button],[type=reset],[type=submit],button{padding:1rem 2.5rem;color:var(--color-darkGrey);background:var(--color-lightGrey);border-radius:4px;border:1px solid transparent;font-size:var(--font-size);line-height:1;text-align:center;-webkit-transition:opacity .2s ease;transition:opacity .2s ease;text-decoration:none;-webkit-transform:scale(1);transform:scale(1);display:inline-block;cursor:pointer}.grouped{display:-webkit-box;display:-ms-flexbox;display:flex}.grouped>:not(:last-child){margin-right:16px}.grouped.gapless>*{margin:0 0 0 -1px!important;border-radius:0!important}.grouped.gapless>:first-child{margin:0!important;border-radius:4px 0 0 4px!important}.grouped.gapless>:last-child{border-radius:0 4px 4px 0!important}.button+.button{margin-left:1rem}.button:hover,[type=button]:hover,[type=reset]:hover,[type=submit]:hover,button:hover{opacity:.8}.button:active,[type=button]:active,[type=reset]:active,[type=submit]:active,button:active{-webkit-transform:scale(.98);transform:scale(.98)}button:disabled,button:disabled:hover,input:disabled,input:disabled:hover{opacity:.4;cursor:not-allowed}.button.dark,.button.error,.button.primary,.button.secondary,.button.success,[type=submit]{color:#fff;z-index:1;background-color:#000;background-color:var(--color-primary)}.button.secondary{background-color:var(--color-grey)}.button.dark{background-color:var(--color-darkGrey)}.button.error{background-color:var(--color-error)}.button.success{background-color:var(--color-success)}.button.outline{background-color:transparent;border-color:var(--color-lightGrey)}.button.outline.primary{border-color:var(--color-primary);color:var(--color-primary)}.button.outline.secondary{border-color:var(--color-grey);color:var(--color-grey)}.button.outline.dark{border-color:var(--color-darkGrey);color:var(--color-darkGrey)}.button.clear{background-color:transparent;border-color:transparent;color:var(--color-primary)}.button.icon{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.button.icon>img{margin-left:2px}.button.icon-only{padding:1rem}::-webkit-input-placeholder{color:#bdbfc4}::-moz-placeholder{color:#bdbfc4}:-ms-input-placeholder{color:#bdbfc4}::-ms-input-placeholder{color:#bdbfc4}::placeholder{color:#bdbfc4}.nav{display:-webkit-box;display:-ms-flexbox;display:flex;min-height:5rem;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch}.nav img{max-height:3rem}.nav-center,.nav-left,.nav-right,.nav>.container{display:-webkit-box;display:-ms-flexbox;display:flex}.nav-center,.nav-left,.nav-right{-webkit-box-flex:1;-ms-flex:1;flex:1}.nav-left{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}.nav-right{-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end}.nav-center{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}@media screen and (max-width:480px){.nav,.nav>.container{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.nav-center,.nav-left,.nav-right{-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}}.nav .brand,.nav a{text-decoration:none;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:1rem 2rem;color:var(--color-darkGrey)}.nav .active:not(.button){color:#000;color:var(--color-primary)}.nav .brand{font-size:1.75em;padding-top:0;padding-bottom:0}.nav .brand img{padding-right:1rem}.nav .button{margin:auto 1rem}.card{padding:1rem 2rem;border-radius:4px;background:var(--bg-color);-webkit-box-shadow:0 1px 3px var(--color-grey);box-shadow:0 1px 3px var(--color-grey)}.card p:last-child{margin:0}.card header>*{margin-top:0;margin-bottom:1rem}.tabs{display:-webkit-box;display:-ms-flexbox;display:flex}.tabs a{text-decoration:none}.tabs>.dropdown>summary,.tabs>a{padding:1rem 2rem;-webkit-box-flex:0;-ms-flex:0 1 auto;flex:0 1 auto;color:var(--color-darkGrey);border-bottom:2px solid var(--color-lightGrey);text-align:center}.tabs>a.active,.tabs>a:hover{opacity:1;border-bottom:2px solid var(--color-darkGrey)}.tabs>a.active{border-color:var(--color-primary)}.tabs.is-full a{-webkit-box-flex:1;-ms-flex:1 1 auto;flex:1 1 auto}.tag{display:inline-block;border:1px solid var(--color-lightGrey);text-transform:uppercase;color:var(--color-grey);padding:.5rem;line-height:1;letter-spacing:.5px}.tag.is-small{padding:.4rem;font-size:.75em}.tag.is-large{padding:.7rem;font-size:1.125em}.tag+.tag{margin-left:1rem}details.dropdown{position:relative;display:inline-block}details.dropdown>:last-child{position:absolute;left:0;white-space:nowrap}.bg-primary{background-color:var(--color-primary)!important}.bg-light{background-color:var(--color-lightGrey)!important}.bg-dark{background-color:var(--color-darkGrey)!important}.bg-grey{background-color:var(--color-grey)!important}.bg-error{background-color:var(--color-error)!important}.bg-success{background-color:var(--color-success)!important}.bd-primary{border:1px solid var(--color-primary)!important}.bd-light{border:1px solid var(--color-lightGrey)!important}.bd-dark{border:1px solid var(--color-darkGrey)!important}.bd-grey{border:1px solid var(--color-grey)!important}.bd-error{border:1px solid var(--color-error)!important}.bd-success{border:1px solid var(--color-success)!important}.text-primary{color:var(--color-primary)!important}.text-light{color:var(--color-lightGrey)!important}.text-dark{color:var(--color-darkGrey)!important}.text-grey{color:var(--color-grey)!important}.text-error{color:var(--color-error)!important}.text-success{color:var(--color-success)!important}.text-white{color:#fff!important}.pull-right{float:right!important}.pull-left{float:left!important}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.text-justify{text-align:justify}.text-uppercase{text-transform:uppercase}.text-lowercase{text-transform:lowercase}.text-capitalize{text-transform:capitalize}.is-full-screen{width:100%;min-height:100vh}.is-full-width{width:100%!important}.is-vertical-align{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.is-center,.is-horizontal-align{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.is-center{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.is-right{-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end}.is-left,.is-right{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.is-left{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}.is-fixed{position:fixed;width:100%}.is-paddingless{padding:0!important}.is-marginless{margin:0!important}.is-pointer{cursor:pointer!important}.is-rounded{border-radius:100%}.clearfix{content:"";display:table;clear:both}.is-hidden{display:none!important}@media screen and (max-width:599px){.hide-xs{display:none!important}}@media screen and (min-width:600px) and (max-width:899px){.hide-sm{display:none!important}}@media screen and (min-width:900px) and (max-width:1199px){.hide-md{display:none!important}}@media screen and (min-width:1200px){.hide-lg{display:none!important}}@media print{.hide-pr{display:none!important}} \ No newline at end of file diff --git a/examples/browser-oembed-parser/public/index.html b/examples/browser-oembed-parser/public/index.html deleted file mode 100644 index 9882314..0000000 --- a/examples/browser-oembed-parser/public/index.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - Example oembed-parser - - - - -
-
-
-

oembed-extractor on browser

-
-
-
- enter oembed link -

- -

-

- - -

-
-
-
- Result -

- -

-
-
-
- - - diff --git a/examples/browser-oembed-parser/server.js b/examples/browser-oembed-parser/server.js deleted file mode 100644 index b2bb294..0000000 --- a/examples/browser-oembed-parser/server.js +++ /dev/null @@ -1,30 +0,0 @@ -// server - -import got from 'got' -import express from 'express' - -const app = express() - -const loadRemoteEmbed = async (url) => { - try { - const headers = { - 'Accept-Charset': 'utf-8', - } - const data = await got(url, { headers }).json() - return data - } catch (err) { - return err.message - } -} - -app.get('/proxy/jsonload', async (req, res) => { - const url = req.query.url - const json = await loadRemoteEmbed(url) - return res.json(json) -}) - -app.use(express.static('public')) - -app.listen(3101, () => { - console.log('Server is running at http://localhost:3101') -}) diff --git a/examples/bun-oembed-parser/.gitignore b/examples/bun-oembed-parser/.gitignore deleted file mode 100644 index f0e3e7e..0000000 --- a/examples/bun-oembed-parser/.gitignore +++ /dev/null @@ -1,171 +0,0 @@ -# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore - -# Logs - -logs -_.log -npm-debug.log_ -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) - -report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json - -# Runtime data - -pids -_.pid -_.seed -\*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover - -lib-cov - -# Coverage directory used by tools like istanbul - -coverage -\*.lcov - -# nyc test coverage - -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) - -.grunt - -# Bower dependency directory (https://bower.io/) - -bower_components - -# node-waf configuration - -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) - -build/Release - -# Dependency directories - -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) - -web_modules/ - -# TypeScript cache - -\*.tsbuildinfo - -# Optional npm cache directory - -.npm - -# Optional eslint cache - -.eslintcache - -# Optional stylelint cache - -.stylelintcache - -# Microbundle cache - -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history - -.node_repl_history - -# Output of 'npm pack' - -\*.tgz - -# Yarn Integrity file - -.yarn-integrity - -# dotenv environment variable files - -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) - -.cache -.parcel-cache - -# Next.js build output - -.next -out - -# Nuxt.js build / generate output - -.nuxt -dist - -# Gatsby files - -.cache/ - -# Comment in the public line in if your project uses Gatsby and not Next.js - -# https://nextjs.org/blog/next-9-1#public-directory-support - -# public - -# vuepress build output - -.vuepress/dist - -# vuepress v2.x temp and cache directory - -.temp -.cache - -# Docusaurus cache and generated files - -.docusaurus - -# Serverless directories - -.serverless/ - -# FuseBox cache - -.fusebox/ - -# DynamoDB Local files - -.dynamodb/ - -# TernJS port file - -.tern-port - -# Stores VSCode versions used for testing VSCode extensions - -.vscode-test - -# yarn v2 - -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.\* - -bun.lockb diff --git a/examples/bun-oembed-parser/README.md b/examples/bun-oembed-parser/README.md deleted file mode 100644 index 9022d87..0000000 --- a/examples/bun-oembed-parser/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# bun-oembed-parser - -To install dependencies: - -```bash -bun install -``` - -To run: - -```bash -bun start -``` - -Open `http://localhost:3101/?url=https://www.youtube.com/watch?v=x2bqscVkGxk` to see the result. - ---- diff --git a/examples/bun-oembed-parser/index.ts b/examples/bun-oembed-parser/index.ts deleted file mode 100644 index 2291ae5..0000000 --- a/examples/bun-oembed-parser/index.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Hono } from 'hono' - -import { extract } from '@extractus/oembed-extractor' - -const app = new Hono() - -const meta = { - service: 'oembed-parser', - lang: 'typescript', - server: 'hono', - platform: 'bun' -} - -app.get('/', async (c) => { - const url = c.req.query('url') - if (!url) { - return c.json(meta) - } - try { - const data = await extract(url) - return c.json({ - error: 0, - message: 'oembed data has been extracted successfully', - data, - meta - }) - } catch (err) { - return c.json({ - error: 1, - message: err.message, - data: null, - meta - }) - } -}) - -export default { - port: 3101, - fetch: app.fetch -} - -console.log('Server is running at http://localhost:3101') diff --git a/examples/bun-oembed-parser/package.json b/examples/bun-oembed-parser/package.json deleted file mode 100644 index 9ed8b15..0000000 --- a/examples/bun-oembed-parser/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "bun-oembed-parser", - "module": "index.ts", - "scripts": { - "start": "bun run index.ts" - }, - "devDependencies": { - "bun-types": "latest" - }, - "dependencies": { - "hono": "latest", - "@extractus/oembed-extractor": "latest" - } -} diff --git a/examples/bun-oembed-parser/tsconfig.json b/examples/bun-oembed-parser/tsconfig.json deleted file mode 100644 index ebdb7d2..0000000 --- a/examples/bun-oembed-parser/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "compilerOptions": { - "lib": ["ESNext"], - "module": "esnext", - "target": "esnext", - // "bun-types" is the important part - "types": ["bun-types"] - } -} diff --git a/examples/deno-oembed-parser/README.md b/examples/deno-oembed-parser/README.md deleted file mode 100644 index 0a0284f..0000000 --- a/examples/deno-oembed-parser/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# deno-oembed-parser - -With `deno`, we have not much thing to do. Just start the server: - -```bash -deno task dev -``` - -Open `http://localhost:3101/?url=https://www.youtube.com/watch?v=x2bqscVkGxk` to see the result. - ---- diff --git a/examples/deno-oembed-parser/deno.json b/examples/deno-oembed-parser/deno.json deleted file mode 100644 index 3690223..0000000 --- a/examples/deno-oembed-parser/deno.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "deno-oembed-parser", - "version": "1.0.0", - "tasks": { - "dev": "deno run --allow-net --allow-env --allow-read index.ts", - }, - "compilerOptions": { - "allowJs": true, - "noImplicitAny": false, - "lib": ["deno.window"], - "strict": true - } -} diff --git a/examples/deno-oembed-parser/index.ts b/examples/deno-oembed-parser/index.ts deleted file mode 100644 index 51c4497..0000000 --- a/examples/deno-oembed-parser/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { serve } from 'https://deno.land/std/http/server.ts' - -import { Hono } from 'https://deno.land/x/hono/mod.ts' - -import { extract } from 'npm:@extractus/oembed-extractor' - -const app = new Hono() - -const meta = { - service: 'oembed-parser', - lang: 'typescript', - server: 'hono', - platform: 'deno' -} - -app.get('/', async (c) => { - const url = c.req.query('url') - if (!url) { - return c.json(meta) - } - try { - const data = await extract(url) - return c.json({ - error: 0, - message: 'oembed data has been extracted successfully', - data, - meta - }) - } catch (err) { - return c.json({ - error: 1, - message: err.message, - data: null, - meta - }) - } -}) - -serve(app.fetch, { - port: 3101, - onListen: () => { - console.log('Server is running at http://localhost:3101') - } -}) diff --git a/examples/node-oembed-parser/.gitignore b/examples/node-oembed-parser/.gitignore deleted file mode 100644 index 48012a9..0000000 --- a/examples/node-oembed-parser/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -# Logs -logs -*.log -*.debug - -# Runtime data -*.pid -*.seed - -node_modules -coverage -.nyc_output - -.DS_Store -yarn.lock -coverage.lcov -pnpm-lock.yaml diff --git a/examples/node-oembed-parser/README.md b/examples/node-oembed-parser/README.md deleted file mode 100644 index dfcf60a..0000000 --- a/examples/node-oembed-parser/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# node-oembed-parser - -Install dependencies: - -```bash -npm i - -# or pnpm, yarn -``` - -Start server: - -```bash -npm start -``` - -Open `http://localhost:3101/?url=https://www.youtube.com/watch?v=x2bqscVkGxk` to see the result. - ---- diff --git a/examples/node-oembed-parser/index.js b/examples/node-oembed-parser/index.js deleted file mode 100644 index 34d628a..0000000 --- a/examples/node-oembed-parser/index.js +++ /dev/null @@ -1,38 +0,0 @@ -import express from 'express' -import { extract } from '@extractus/oembed-extractor' - -const app = express() - -const meta = { - service: 'oembed-parser', - lang: 'javascript', - server: 'express', - platform: 'node', -} - -app.get('/', async (req, res) => { - const url = req.query.url - if (!url) { - return res.json(meta) - } - try { - const data = await extract(url) - return res.json({ - error: 0, - message: 'oembed data has been extracted successfully', - data, - meta, - }) - } catch (err) { - return res.json({ - error: 1, - message: err.message, - data: null, - meta, - }) - } -}) - -app.listen(3101, () => { - console.log('Server is running at http://localhost:3101') -}) diff --git a/examples/node-oembed-parser/package.json b/examples/node-oembed-parser/package.json deleted file mode 100644 index 5592617..0000000 --- a/examples/node-oembed-parser/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "node-oembed-parser", - "version": "1.0.0", - "main": "index.js", - "type": "module", - "scripts": { - "start": "node index.js" - }, - "dependencies": { - "express": "latest", - "@extractus/oembed-extractor": "latest" - } -} diff --git a/examples/tsnode-oembed-parser/.gitignore b/examples/tsnode-oembed-parser/.gitignore deleted file mode 100644 index 5bad394..0000000 --- a/examples/tsnode-oembed-parser/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -# Logs -logs -*.log -*.debug - -# Runtime data -*.pid -*.seed - -node_modules -coverage -.nyc_output - -.DS_Store -yarn.lock -coverage.lcov -pnpm-lock.yaml - -dist diff --git a/examples/tsnode-oembed-parser/README.md b/examples/tsnode-oembed-parser/README.md deleted file mode 100644 index 8a1903f..0000000 --- a/examples/tsnode-oembed-parser/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# tsnode-oembed-parser - -Install dependencies: - -```bash -npm i - -# or pnpm, yarn -``` - -Build typescript source to javascript and start server: - -```bash -npm start -``` - -Open `http://localhost:3101/?url=https://www.youtube.com/watch?v=x2bqscVkGxk` to see the result. - ---- diff --git a/examples/tsnode-oembed-parser/index.ts b/examples/tsnode-oembed-parser/index.ts deleted file mode 100644 index 90559d9..0000000 --- a/examples/tsnode-oembed-parser/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -import express from 'express' -import { extract } from '@extractus/oembed-extractor' - -const app = express() - -const meta = { - service: 'oembed-parser', - lang: 'typescript', - server: 'express', - platform: 'node' -} - -app.get('/', async (req, res) => { - const url = req.query.url - if (!url) { - return res.json(meta) - } - try { - const data = await extract(url) - return res.json({ - error: 0, - message: 'oembed data has been extracted successfully', - data, - meta - }) - } catch (err) { - return res.json({ - error: 1, - message: err.message, - data: null, - meta - }) - } -}) - -app.listen(3101, () => { - console.log('Server is running at http://localhost:3101') -}) diff --git a/examples/tsnode-oembed-parser/package.json b/examples/tsnode-oembed-parser/package.json deleted file mode 100644 index c3128b4..0000000 --- a/examples/tsnode-oembed-parser/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "tsnode-oembed-parser", - "version": "1.0.0", - "main": "dist/index.js", - "scripts": { - "prestart": "npx tsc", - "start": "node dist/index.js" - }, - "devDependencies": { - "typescript": "latest" - }, - "dependencies": { - "express": "latest", - "@extractus/oembed-extractor": "latest" - } -} diff --git a/examples/tsnode-oembed-parser/tsconfig.json b/examples/tsnode-oembed-parser/tsconfig.json deleted file mode 100644 index d58a717..0000000 --- a/examples/tsnode-oembed-parser/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "esModuleInterop": true, - "target": "es6", - "moduleResolution": "node", - "sourceMap": true, - "outDir": "dist" - }, - "lib": ["es2015"] -} diff --git a/package.json b/package.json index 52235e3..fe9a9ca 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.0.8", + "version": "4.0.9", "name": "@extractus/oembed-extractor", "description": "Get oEmbed data from given URL.", "homepage": "https://github.com/extractus/oembed-extractor", @@ -25,22 +25,21 @@ "lint": "eslint .", "lint:fix": "eslint --fix .", "pretest": "npm run lint", - "test": "NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules jest --verbose --coverage=true", + "test": "node --test --experimental-test-coverage", "eval": "node eval", "sync": "node sync", "reset": "node reset" }, "dependencies": { "cross-fetch": "^4.1.0", - "linkedom": "^0.18.10" + "linkedom": "^0.18.12" }, "devDependencies": { - "@eslint/js": "^9.26.0", - "eslint": "^9.26.0", - "globals": "^16.0.0", + "@eslint/js": "^9.34.0", + "eslint": "^9.34.0", + "globals": "^16.3.0", "https-proxy-agent": "^7.0.6", - "jest": "^29.7.0", - "nock": "^14.0.4" + "nock": "^14.0.10" }, "keywords": [ "oembed", diff --git a/src/main.test.js b/src/main.test.js index c2dc454..7ffecc6 100644 --- a/src/main.test.js +++ b/src/main.test.js @@ -1,5 +1,7 @@ -// main -/* eslint-env jest */ +// main.test + +import { describe, it } from 'node:test' +import assert from 'node:assert' import { HttpsProxyAgent } from 'https-proxy-agent' @@ -93,11 +95,11 @@ describe('test extract(bad url)', () => { ] badSamples.forEach((url) => { - test(`testing extract bad url "${url}"`, async () => { + it(`testing extract bad url "${url}"`, async () => { try { await extract(url) } catch (err) { - expect(err).toBeTruthy() + assert.ok(err) } }) }) @@ -168,7 +170,7 @@ describe('test if extract() with some popular providers', () => { cases.forEach(({ input, expected, checkFn }) => { const { url, file, params = {} } = input - test(`check fetchEmbed("${url}")`, async () => { + it(`check fetchEmbed("${url}")`, async () => { const provider = findProvider(url) const { baseUrl, path } = parseUrl(provider.endpoint) @@ -190,15 +192,15 @@ describe('test if extract() with some popular providers', () => { } = params const result = await extract(url, { maxwidth, maxheight }) - expect(result).toBeTruthy() - expect(checkFn(result)).toBe(true) - expect(result.provider_name).toEqual(expected.provider_name) - expect(result.type).toEqual(expected.type) + assert.ok(result) + assert.ok(checkFn(result)) + assert.ok(result.provider_name === expected.provider_name) + assert.ok(result.type === expected.type) if (maxwidth > 0) { - expect(result.width).toBeLessThanOrEqual(expected.maxwidth) + assert.ok(result.width <= expected.maxwidth) } if (maxheight > 0) { - expect(result.height).toBeLessThanOrEqual(expected.maxheight) + assert.ok(result.height <= expected.maxheight) } nock.cleanAll() }) @@ -207,23 +209,23 @@ describe('test if extract() with some popular providers', () => { if (PROXY_SERVER !== '') { describe('test extract live oembed API via proxy server', () => { - test('check if extract method works with proxy server', async () => { + it('check if extract method works with proxy server', async () => { const url = 'https://codepen.io/ndaidong/pen/LYmLKBw' const result = await extract(url, {}, { agent: new HttpsProxyAgent(PROXY_SERVER), }) console.log(result) - expect(result.success).toBeTruthy() + assert.ok(result.success) }, 10000) }) } -test('test .hasProvider() method', () => { - expect(hasProvider('https://www.youtube.com/watch?v=ciS8aCrX-9s')).toBe(true) - expect(hasProvider('https://trello.com/b/BO3bg7yn/notes')).toBe(false) +it('test .hasProvider() method', () => { + assert.ok(hasProvider('https://www.youtube.com/watch?v=ciS8aCrX-9s')) + assert.ok(!hasProvider('https://trello.com/b/BO3bg7yn/notes')) }) -test('test .setProviderList() method', () => { +it('test .setProviderList() method', () => { const customProviderOnly = [ { provider_name: 'Example', @@ -239,6 +241,6 @@ test('test .setProviderList() method', () => { }, ] setProviderList(customProviderOnly) - expect(hasProvider('http://www.example.org/media/abcdef')).toBe(true) - expect(hasProvider('https://www.youtube.com/watch?v=ciS8aCrX-9s')).toBe(false) + assert.ok(hasProvider('http://www.example.org/media/abcdef')) + assert.ok(!hasProvider('https://www.youtube.com/watch?v=ciS8aCrX-9s')) }) diff --git a/src/utils/autoDiscovery.js b/src/utils/autoDiscovery.js index c080292..a6b4cfb 100644 --- a/src/utils/autoDiscovery.js +++ b/src/utils/autoDiscovery.js @@ -8,6 +8,9 @@ export default async (url, params = {}, options = {}) => { const html = await getHtml(url, options) const doc = new DOMParser().parseFromString(html, 'text/html') const elm = doc.querySelector('link[type="application/json+oembed"]') + if (!elm) { + throw new Error('No oEmbed link found') + } const href = elm.getAttribute('href') const q = new URL(href) const { origin, pathname, searchParams } = q diff --git a/src/utils/autoDiscovery.test.js b/src/utils/autoDiscovery.test.js index 701ae69..ba2178d 100644 --- a/src/utils/autoDiscovery.test.js +++ b/src/utils/autoDiscovery.test.js @@ -1,5 +1,7 @@ // autoDiscovery.test -/* eslint-env jest */ + +import { describe, it } from 'node:test' +import assert from 'node:assert' import nock from 'nock' @@ -15,7 +17,7 @@ const parseUrl = (url) => { describe('test if autoDiscovery() works correctly', () => { const url = 'https://www.bitchute.com/video/8hXWnkvA8Ao/' - test(`check fetchEmbed("${url}")`, async () => { + it(`check fetchEmbed("${url}")`, async () => { const htmlFile = './test-data/bitchute.html' const jsonFile = './test-data/bitchute.json' @@ -47,7 +49,7 @@ describe('test if autoDiscovery() works correctly', () => { }) const result = await autoDiscovery(url, params) - expect(result).toBeTruthy() + assert.ok(result) nock.cleanAll() }) }) diff --git a/src/utils/fetchEmbed.test.js b/src/utils/fetchEmbed.test.js index aa0c9d7..86d39d4 100644 --- a/src/utils/fetchEmbed.test.js +++ b/src/utils/fetchEmbed.test.js @@ -1,5 +1,7 @@ // fetchEmbed.test -/* eslint-env jest */ + +import { describe, it } from 'node:test' +import assert from 'node:assert' import nock from 'nock' @@ -91,7 +93,7 @@ describe('test if fetchEmbed() works correctly', () => { cases.forEach(({ input, expected }) => { const { url, file, params = {} } = input - test(`check fetchEmbed("${url}")`, async () => { + it(`check fetchEmbed("${url}")`, async () => { const endpoint = getEndpoint(url) const { baseUrl, path } = parseUrl(endpoint) @@ -113,14 +115,14 @@ describe('test if fetchEmbed() works correctly', () => { } = params const result = await fetchEmbed(url, { maxwidth, maxheight }, endpoint) - expect(result).toBeTruthy() - expect(result.provider_name).toEqual(expected.provider_name) - expect(result.type).toEqual(expected.type) + assert.ok(result) + assert.equal(result.provider_name, expected.provider_name) + assert.equal(result.type, expected.type) if (maxwidth > 0) { - expect(result.width).toBeLessThanOrEqual(expected.maxwidth) + assert.ok(result.width <= expected.maxwidth) } if (maxheight > 0) { - expect(result.height).toBeLessThanOrEqual(expected.maxheight) + assert.ok(result.height <= expected.maxheight) } nock.cleanAll() }) diff --git a/src/utils/linker.test.js b/src/utils/linker.test.js index ad40a1e..2dee4c7 100644 --- a/src/utils/linker.test.js +++ b/src/utils/linker.test.js @@ -1,5 +1,7 @@ // linker.test -/* eslint-env jest */ + +import { describe, it } from 'node:test' +import assert from 'node:assert' import { isValid as isValidURL } from './linker.js' @@ -39,9 +41,9 @@ describe('test isValidURL()', () => { }, ] cases.forEach(({ url, expected }) => { - test(`isValidURL("${url}") must return "${expected}"`, () => { + it(`isValidURL("${url}") must return "${expected}"`, () => { const result = isValidURL(url) - expect(result).toEqual(expected) + assert.equal(result, expected) }) }) }) diff --git a/src/utils/provider.test.js b/src/utils/provider.test.js index 39a7e61..f971153 100644 --- a/src/utils/provider.test.js +++ b/src/utils/provider.test.js @@ -1,5 +1,7 @@ // provider.test -/* eslint-env jest */ + +import { describe, it } from 'node:test' +import assert from 'node:assert' import provider from './provider.js' @@ -20,22 +22,22 @@ describe('test if provider.find() works correctly', () => { ] cases.forEach(({ url, fetchEndpoint }) => { - test(`provider.find("${url}") must return "${fetchEndpoint}"`, () => { + it(`provider.find("${url}") must return "${fetchEndpoint}"`, () => { const foundedProvider = provider.find(url) - expect(foundedProvider.endpoint).toEqual(fetchEndpoint) + assert.equal(foundedProvider.endpoint, fetchEndpoint) }) }) - test('provider.find("{}") must return null', () => { - expect(provider.find({})).toEqual(null) + it('provider.find("{}") must return null', () => { + assert.equal(provider.find({}), null) }) - test('provider.find("abcdef") must return null', () => { - expect(provider.find('abcdef')).toEqual(null) + it('provider.find("abcdef") must return null', () => { + assert.equal(provider.find('abcdef'), null) }) - test('provider.find("https://somethingdoesnotexist.com") must return null', () => { - expect(provider.find('https://somethingdoesnotexist.com')).toEqual(null) + it('provider.find("https://somethingdoesnotexist.com") must return null', () => { + assert.equal(provider.find('https://somethingdoesnotexist.com'), null) }) }) @@ -66,10 +68,10 @@ describe('test if provider set/get works correctly', () => { ], }, ] - test('provider.set() & provider.get()', () => { - expect(provider.set(providerList)).toEqual(providerList.length) + it('provider.set() & provider.get()', () => { + assert.equal(provider.set(providerList), providerList.length) const newList = provider.get() - expect(newList.length).toEqual(providerList.length) - expect(newList[0].schemes[0]).toEqual(/\/\/store.alpha.com\/(.*)/i) + assert.equal(newList.length, providerList.length) + assert.equal((newList[0].schemes[0]).toString(), (/\/\/store.alpha.com\/(.*)/i).toString()) }) }) diff --git a/src/utils/providers.latest.js b/src/utils/providers.latest.js index c62652d..c9474bb 100644 --- a/src/utils/providers.latest.js +++ b/src/utils/providers.latest.js @@ -1,4 +1,4 @@ -// provider data, synchronized at 2025-05-04T13:26:33.140Z +// provider data, synchronized at 2025-09-04T09:00:29.575Z /* eslint-disable */ @@ -49,16 +49,6 @@ export const providers = [ ], "e": "//openapi.afreecatv.com/oembed/embedinfo" }, - { - "s": [ - "//vod\\.sooplive\\.co\\.kr/player/", - "//v\\.afree\\.ca/ST/", - "//vod\\.sooplive\\.co\\.kr/ST/", - "//vod\\.sooplive\\.co\\.kr/PLAYER/STATION/", - "//play\\.sooplive\\.co\\.kr/" - ], - "e": "//openapi.sooplive.co.kr/oembed/embedinfo" - }, { "s": [ "//altium\\.com/viewer/*" @@ -204,6 +194,12 @@ export const providers = [ ], "e": "//www.behance.net/services/oembed" }, + { + "s": [ + "//beta\\.quellensuche\\.de/*" + ], + "e": "//beta.quellensuche.de/api/oembed" + }, { "s": [ "//cloud\\.biqapp\\.com/*" @@ -295,6 +291,13 @@ export const providers = [ ], "e": "//www.canva.com/_oembed" }, + { + "s": [ + "//carbon\\.music/*", + "//www\\.carbon\\.music/*" + ], + "e": "//carbon.music/oembed" + }, { "s": [ "//minesweeper\\.today/*" @@ -583,6 +586,12 @@ export const providers = [ ], "e": "//api.everviz.com/oembed" }, + { + "s": [ + "//cdn\\.everwall\\.com/hubs/iframe/*" + ], + "e": "//cdn.everwall.com/hubs/oembed" + }, { "s": [ "//app\\.ex\\.co/stories/*", @@ -647,6 +656,12 @@ export const providers = [ ], "e": "//www.figma.com/api/oembed" }, + { + "s": [ + "//app\\.filestage\\.io/step/**" + ], + "e": "//app.filestage.io/oembed" + }, { "s": [ "//*\\.fireworktv\\.com/*", @@ -697,6 +712,12 @@ export const providers = [ ], "e": "//fooday.app/oembed" }, + { + "s": [ + "//forms\\.form-data\\.com/*" + ], + "e": "//forms.form-data.com/api/oembed" + }, { "s": [ "//fiso\\.foxsports\\.com\\.au/isomorphic-widget/*" @@ -808,6 +829,12 @@ export const providers = [ ], "e": "//api.gumlet.com/v1/oembed" }, + { + "s": [ + "//gw2fashions\\.com/fashion/*" + ], + "e": "//gw2fashions.com/fashion/oembed" + }, { "s": [ "//gyazo\\.com/*" @@ -1100,6 +1127,13 @@ export const providers = [ ], "e": "//embed.kooapp.com/services/oembed" }, + { + "s": [ + "//kubit\\.ai/*", + "//*\\.kubit\\.ai/*" + ], + "e": "//kubit.ai/services/oembed" + }, { "s": [ "//kurozora\\.app/episodes/*", @@ -1209,7 +1243,8 @@ export const providers = [ }, { "s": [ - "//medienarchiv\\.zhdk\\.ch/entries/*" + "//medienarchiv\\.zhdk\\.ch/entries/*", + "//zhdk\\.medienarchiv\\.ch/entries/*" ], "e": "//medienarchiv.zhdk.ch/oembed.json" }, @@ -1314,6 +1349,13 @@ export const providers = [ ], "e": "//naturalatlas.com/oembed.json" }, + { + "s": [ + "//naver\\.me/*", + "//m\\.naver\\.com/shorts/*" + ], + "e": "//m.naver.com/shorts/oEmbed" + }, { "s": [ "//ndla\\.no/*", @@ -1586,6 +1628,12 @@ export const providers = [ ], "e": "//web.quartr.com/api/oembed" }, + { + "s": [ + "//quellensuche\\.de/*" + ], + "e": "//quellensuche.de/api/oembed" + }, { "s": [ "//www\\.quiz\\.biz/quizz-*\\.html" @@ -1869,6 +1917,16 @@ export const providers = [ ], "e": "//www.socialexplorer.com/services/oembed/" }, + { + "s": [ + "//vod\\.sooplive\\.co\\.kr/player/", + "//v\\.afree\\.ca/ST/", + "//vod\\.sooplive\\.co\\.kr/ST/", + "//vod\\.sooplive\\.co\\.kr/PLAYER/STATION/", + "//play\\.sooplive\\.co\\.kr/" + ], + "e": "//openapi.sooplive.co.kr/oembed/embedinfo" + }, { "s": [ "//soundcloud\\.com/*", @@ -1960,9 +2018,9 @@ export const providers = [ }, { "s": [ - "//supercut\\.video/share/*" + "//supercut\\.ai/share/*" ], - "e": "//supercut.video/oembed" + "e": "//supercut.ai/oembed" }, { "s": [ @@ -2295,11 +2353,9 @@ export const providers = [ }, { "s": [ - "//share\\.webcrumbs\\.org/*", - "//tools\\.webcrumbs\\.org/*", - "//www\\.webcrumbs\\.org/*" + "//plugins\\.webcrumbs\\.dev/*" ], - "e": "//share.webcrumbs.org/" + "e": "//webcrumbs.dev/oembed" }, { "s": [ diff --git a/src/utils/providers.orginal.json b/src/utils/providers.orginal.json index 4580f4c..2c3a4d7 100644 --- a/src/utils/providers.orginal.json +++ b/src/utils/providers.orginal.json @@ -98,23 +98,6 @@ } ] }, - { - "provider_name": "afreecaTV", - "provider_url": "https://www.sooplive.co.kr", - "endpoints": [ - { - "schemes": [ - "https://vod.sooplive.co.kr/player/", - "https://v.afree.ca/ST/", - "https://vod.sooplive.co.kr/ST/", - "https://vod.sooplive.co.kr/PLAYER/STATION/", - "https://play.sooplive.co.kr/" - ], - "url": "https://openapi.sooplive.co.kr/oembed/embedinfo", - "discovery": true - } - ] - }, { "provider_name": "Altium LLC", "provider_url": "https://altium.com", @@ -419,6 +402,22 @@ } ] }, + { + "provider_name": "Beta QuellenSuche", + "provider_url": "http://beta.quellensuche.de", + "endpoints": [ + { + "schemes": [ + "http://beta.quellensuche.de/*" + ], + "url": "http://beta.quellensuche.de/api/oembed", + "discovery": true, + "formats": [ + "json" + ] + } + ] + }, { "provider_name": "biqnetwork", "provider_url": "https://biqapp.com/", @@ -622,6 +621,23 @@ } ] }, + { + "provider_name": "Carbon", + "provider_url": "https://carbon.music/", + "endpoints": [ + { + "schemes": [ + "https://carbon.music/*", + "https://www.carbon.music/*" + ], + "url": "https://carbon.music/oembed", + "discovery": true, + "formats": [ + "json" + ] + } + ] + }, { "provider_name": "Cardinal Blue", "provider_url": "https://minesweeper.today/", @@ -1242,6 +1258,19 @@ } ] }, + { + "provider_name": "Everwall", + "provider_url": "https://everwall.com", + "endpoints": [ + { + "schemes": [ + "https://cdn.everwall.com/hubs/iframe/*" + ], + "url": "https://cdn.everwall.com/hubs/oembed", + "discovery": true + } + ] + }, { "provider_name": "Ex.Co", "provider_url": "https://ex.co", @@ -1352,6 +1381,23 @@ } ] }, + { + "provider_name": "Filestage", + "provider_url": "https://filestage.io/", + "endpoints": [ + { + "schemes": [ + "https://app.filestage.io/step/**" + ], + "url": "https://app.filestage.io/oembed", + "discovery": true, + "formats": [ + "json", + "xml" + ] + } + ] + }, { "provider_name": "Firework", "provider_url": "https://fireworktv.com/", @@ -1455,6 +1501,22 @@ } ] }, + { + "provider_name": "Form-Data", + "provider_url": "https://form-data.com", + "endpoints": [ + { + "schemes": [ + "https://forms.form-data.com/*" + ], + "url": "https://forms.form-data.com/api/oembed", + "formats": [ + "json" + ], + "discovery": true + } + ] + }, { "provider_name": "FOX SPORTS Australia", "provider_url": "http://www.foxsports.com.au", @@ -1677,6 +1739,19 @@ } ] }, + { + "provider_name": "GW2 Fashions", + "provider_url": "https://gw2fashions.com/", + "endpoints": [ + { + "schemes": [ + "https://gw2fashions.com/fashion/*" + ], + "url": "https://gw2fashions.com/fashion/oembed", + "discovery": true + } + ] + }, { "provider_name": "Gyazo", "provider_url": "https://gyazo.com", @@ -2300,6 +2375,20 @@ } ] }, + { + "provider_name": "Kubit", + "provider_url": "https://kubit.ai", + "endpoints": [ + { + "schemes": [ + "https://kubit.ai/*", + "https://*.kubit.ai/*" + ], + "url": "https://kubit.ai/services/oembed", + "discovery": true + } + ] + }, { "provider_name": "Kurozora", "provider_url": "https://kurozora.app/", @@ -2532,7 +2621,8 @@ "endpoints": [ { "schemes": [ - "https://medienarchiv.zhdk.ch/entries/*" + "https://medienarchiv.zhdk.ch/entries/*", + "https://zhdk.medienarchiv.ch/entries/*" ], "url": "https://medienarchiv.zhdk.ch/oembed.{format}", "discovery": true @@ -2757,6 +2847,20 @@ } ] }, + { + "provider_name": "Naver Clip", + "provider_url": "https://m.naver.com/shorts", + "endpoints": [ + { + "schemes": [ + "https://naver.me/*", + "https://m.naver.com/shorts/*" + ], + "url": "https://m.naver.com/shorts/oEmbed", + "discovery": true + } + ] + }, { "provider_name": "NDLA - Norwegian Digital Learning Arena", "provider_url": "https://ndla.no", @@ -3338,6 +3442,22 @@ } ] }, + { + "provider_name": "QuellenSuche", + "provider_url": "http://quellensuche.de", + "endpoints": [ + { + "schemes": [ + "http://quellensuche.de/*" + ], + "url": "http://quellensuche.de/api/oembed", + "discovery": true, + "formats": [ + "json" + ] + } + ] + }, { "provider_name": "Quiz.biz", "provider_url": "http://www.quiz.biz/", @@ -3931,6 +4051,23 @@ } ] }, + { + "provider_name": "SOOP", + "provider_url": "https://www.sooplive.co.kr", + "endpoints": [ + { + "schemes": [ + "https://vod.sooplive.co.kr/player/", + "https://v.afree.ca/ST/", + "https://vod.sooplive.co.kr/ST/", + "https://vod.sooplive.co.kr/PLAYER/STATION/", + "https://play.sooplive.co.kr/" + ], + "url": "https://openapi.sooplive.co.kr/oembed/embedinfo", + "discovery": true + } + ] + }, { "provider_name": "SoundCloud", "provider_url": "http://soundcloud.com/", @@ -4129,13 +4266,13 @@ }, { "provider_name": "Supercut", - "provider_url": "https://supercut.video/", + "provider_url": "https://supercut.ai/", "endpoints": [ { "schemes": [ - "https://supercut.video/share/*" + "https://supercut.ai/share/*" ], - "url": "https://supercut.video/oembed", + "url": "https://supercut.ai/oembed", "discovery": true } ] @@ -4850,11 +4987,13 @@ "endpoints": [ { "schemes": [ - "https://share.webcrumbs.org/*", - "https://tools.webcrumbs.org/*", - "https://www.webcrumbs.org/*" + "https://plugins.webcrumbs.dev/*" + ], + "url": "https://webcrumbs.dev/oembed", + "formats": [ + "json", + "xml" ], - "url": "http://share.webcrumbs.org/", "discovery": true } ] diff --git a/src/utils/providers.prev.js b/src/utils/providers.prev.js index 2654b04..c62652d 100644 --- a/src/utils/providers.prev.js +++ b/src/utils/providers.prev.js @@ -1,4 +1,4 @@ -// provider data, synchronized at 2025-04-13T02:12:06.847Z +// provider data, synchronized at 2025-05-04T13:26:33.140Z /* eslint-disable */ @@ -804,7 +804,6 @@ export const providers = [ { "s": [ "//gumlet\\.tv/watch/*", - "//www\\.gumlet\\.com/watch/*", "//play\\.gumlet\\.io/embed/*" ], "e": "//api.gumlet.com/v1/oembed" @@ -909,6 +908,13 @@ export const providers = [ ], "e": "//www.ifttt.com/oembed/" }, + { + "s": [ + "//*\\.videocdn\\.net/player/*", + "//*\\.euvideocdn\\.com/player/*" + ], + "e": "//app.ignitevideo.cloud/api/oembed" + }, { "s": [ "//www\\.iheart\\.com/podcast/*/*" @@ -1171,6 +1177,12 @@ export const providers = [ ], "e": "//admin.lumiere.is/api/services/oembed" }, + { + "s": [ + "//marimo\\.app/*" + ], + "e": "//marimo.app/oembed" + }, { "s": [ "//mathembed\\.com/latex?inputText=*" diff --git a/src/utils/retrieve.test.js b/src/utils/retrieve.test.js index c67f671..e312157 100644 --- a/src/utils/retrieve.test.js +++ b/src/utils/retrieve.test.js @@ -1,5 +1,7 @@ // retrieve.test -/* eslint-env jest */ + +import { describe, it } from 'node:test' +import assert from 'node:assert' import nock from 'nock' @@ -14,18 +16,18 @@ const parseUrl = (url) => { } describe('test getJson() method', () => { - test('test getJson from good source', async () => { + it('test getJson from good source', async () => { const url = 'https://some.where/good/source' const { baseUrl, path } = parseUrl(url) nock(baseUrl).get(path).reply(200, { data: { name: 'oembed-parser' } }, { 'Content-Type': 'application/json', }) const result = await getJson(url) - expect(result.data.name).toEqual('oembed-parser') + assert.equal(result.data.name, 'oembed-parser') nock.cleanAll() }) - test('test getJson using proxy', async () => { + it('test getJson using proxy', async () => { const url = 'https://some.where/good/source-with-proxy' const { baseUrl, path } = parseUrl(url) nock(baseUrl).get(path).reply(200, { data: { name: 'oembed-parser' } }, { @@ -40,11 +42,11 @@ describe('test getJson() method', () => { target: 'https://proxy-server.com/api/proxy?url=', }, }) - expect(result.data.name).toEqual('oembed-parser') + assert.equal(result.data.name, 'oembed-parser') nock.cleanAll() }) - test('test getJson invalid json reponsse', async () => { + it('test getJson invalid json reponsse', async () => { const url = 'https://some.where/bad/source' const { baseUrl, path } = parseUrl(url) nock(baseUrl).get(path).reply(200, 'this is not json string', { @@ -53,7 +55,7 @@ describe('test getJson() method', () => { try { await getJson(url) } catch (err) { - expect(err).toBeTruthy() + assert.ok(err) } nock.cleanAll() })