@kulkul/tinyurl-client 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/dependabot-automerge.yml +25 -0
- package/.github/workflows/test-and-publish.yml +57 -0
- package/README.md +7 -4
- package/dist/main.js +8 -1
- package/package.json +2 -2
- package/src/index.js +34 -9
- package/tests/index.test.js +73 -205
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Dependabot auto-merge
|
|
2
|
+
on: pull_request
|
|
3
|
+
|
|
4
|
+
permissions:
|
|
5
|
+
contents: write
|
|
6
|
+
pull-requests: write
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
dependabot:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'kulkultech/tinyurl-client'
|
|
12
|
+
steps:
|
|
13
|
+
- name: Dependabot metadata
|
|
14
|
+
id: metadata
|
|
15
|
+
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7
|
|
16
|
+
with:
|
|
17
|
+
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
18
|
+
- name: Enable auto-merge for Dependabot PRs
|
|
19
|
+
if: |
|
|
20
|
+
steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
|
|
21
|
+
steps.metadata.outputs.update-type == 'version-update:semver-minor'
|
|
22
|
+
run: gh pr merge --auto --merge "$PR_URL"
|
|
23
|
+
env:
|
|
24
|
+
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
25
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: Test and Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- master
|
|
10
|
+
release:
|
|
11
|
+
types: [created]
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
matrix:
|
|
18
|
+
node-version: [14, 16]
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v3
|
|
21
|
+
|
|
22
|
+
- name: Setup Node.js ${{ matrix.node-version }}
|
|
23
|
+
uses: actions/setup-node@v3
|
|
24
|
+
with:
|
|
25
|
+
node-version: ${{ matrix.node-version }}
|
|
26
|
+
cache: 'yarn'
|
|
27
|
+
|
|
28
|
+
- name: Install dependencies
|
|
29
|
+
run: yarn install --frozen-lockfile
|
|
30
|
+
|
|
31
|
+
- name: Run tests
|
|
32
|
+
run: yarn test
|
|
33
|
+
|
|
34
|
+
publish:
|
|
35
|
+
needs: test
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
if: github.event_name == 'release' && github.event.action == 'created'
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v3
|
|
40
|
+
|
|
41
|
+
- name: Setup Node.js
|
|
42
|
+
uses: actions/setup-node@v3
|
|
43
|
+
with:
|
|
44
|
+
node-version: '16'
|
|
45
|
+
registry-url: 'https://registry.npmjs.org'
|
|
46
|
+
cache: 'yarn'
|
|
47
|
+
|
|
48
|
+
- name: Install dependencies
|
|
49
|
+
run: yarn install --frozen-lockfile
|
|
50
|
+
|
|
51
|
+
- name: Build
|
|
52
|
+
run: yarn build
|
|
53
|
+
|
|
54
|
+
- name: Publish to NPM
|
|
55
|
+
run: yarn publish --access public --non-interactive
|
|
56
|
+
env:
|
|
57
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/README.md
CHANGED
|
@@ -18,16 +18,19 @@ Easily use TinyURL in your browser.
|
|
|
18
18
|
import shortenUrl from "@kulkul/tinyurl-client";
|
|
19
19
|
|
|
20
20
|
shortenUrl("https://kulkul.tech").then((result) => {
|
|
21
|
-
console.log({ result }); // https://tinyurl.com/<slug>
|
|
21
|
+
console.log({ result }); // https://tinyurl.com/<random-slug>
|
|
22
22
|
});
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
## Important Note on Custom Aliases
|
|
26
|
+
|
|
27
|
+
**Custom aliases are no longer supported.** The underlying TinyURL API endpoint used by this client does not support custom aliases. Any alias parameter provided will be ignored, and a random slug will be generated instead.
|
|
26
28
|
|
|
27
29
|
```javascript
|
|
28
30
|
import shortenUrl from "@kulkul/tinyurl-client";
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
// Alias parameter is deprecated and will be ignored
|
|
33
|
+
shortenUrl("https://kulkul.tech", "my-custom-alias").then((result) => {
|
|
34
|
+
console.log({ result }); // https://tinyurl.com/<random-slug> (NOT my-custom-alias)
|
|
32
35
|
});
|
|
33
36
|
```
|
package/dist/main.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=10)}([function(e,t,r){"use strict";var n=r(1),o=Object.prototype.toString;function i(e){return"[object Array]"===o.call(e)}function s(e){return void 0===e}function u(e){return null!==e&&"object"==typeof e}function a(e){return"[object Function]"===o.call(e)}function c(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:i,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:u,isUndefined:s,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:a,isStream:function(e){return u(e)&&a(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:c,merge:function e(){var t={};function r(r,n){"object"==typeof t[n]&&"object"==typeof r?t[n]=e(t[n],r):t[n]=r}for(var n=0,o=arguments.length;n<o;n++)c(arguments[n],r);return t},deepMerge:function e(){var t={};function r(r,n){"object"==typeof t[n]&&"object"==typeof r?t[n]=e(t[n],r):t[n]="object"==typeof r?e({},r):r}for(var n=0,o=arguments.length;n<o;n++)c(arguments[n],r);return t},extend:function(e,t,r){return c(t,(function(t,o){e[o]=r&&"function"==typeof t?n(t,r):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t,r){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}}},function(e,t,r){"use strict";var n=r(0);function o(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,r){if(!t)return e;var i;if(r)i=r(t);else if(n.isURLSearchParams(t))i=t.toString();else{var s=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),s.push(o(t)+"="+o(e))})))})),i=s.join("&")}if(i){var u=e.indexOf("#");-1!==u&&(e=e.slice(0,u)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}},function(e,t,r){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,r){"use strict";(function(t){var n=r(0),o=r(17),i={"Content-Type":"application/x-www-form-urlencoded"};function s(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var u,a={adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==t&&"[object process]"===Object.prototype.toString.call(t))&&(u=r(5)),u),transformRequest:[function(e,t){return o(t,"Accept"),o(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(s(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)?(s(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};a.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],(function(e){a.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){a.headers[e]=n.merge(i)})),e.exports=a}).call(this,r(16))},function(e,t,r){"use strict";var n=r(0),o=r(18),i=r(2),s=r(20),u=r(23),a=r(24),c=r(6);e.exports=function(e){return new Promise((function(t,f){var p=e.data,l=e.headers;n.isFormData(p)&&delete l["Content-Type"];var d=new XMLHttpRequest;if(e.auth){var h=e.auth.username||"",m=e.auth.password||"";l.Authorization="Basic "+btoa(h+":"+m)}var y=s(e.baseURL,e.url);if(d.open(e.method.toUpperCase(),i(y,e.params,e.paramsSerializer),!0),d.timeout=e.timeout,d.onreadystatechange=function(){if(d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in d?u(d.getAllResponseHeaders()):null,n={data:e.responseType&&"text"!==e.responseType?d.response:d.responseText,status:d.status,statusText:d.statusText,headers:r,config:e,request:d};o(t,f,n),d=null}},d.onabort=function(){d&&(f(c("Request aborted",e,"ECONNABORTED",d)),d=null)},d.onerror=function(){f(c("Network Error",e,null,d)),d=null},d.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),f(c(t,e,"ECONNABORTED",d)),d=null},n.isStandardBrowserEnv()){var v=r(25),g=(e.withCredentials||a(y))&&e.xsrfCookieName?v.read(e.xsrfCookieName):void 0;g&&(l[e.xsrfHeaderName]=g)}if("setRequestHeader"in d&&n.forEach(l,(function(e,t){void 0===p&&"content-type"===t.toLowerCase()?delete l[t]:d.setRequestHeader(t,e)})),n.isUndefined(e.withCredentials)||(d.withCredentials=!!e.withCredentials),e.responseType)try{d.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&d.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){d&&(d.abort(),f(e),d=null)})),void 0===p&&(p=null),d.send(p)}))}},function(e,t,r){"use strict";var n=r(19);e.exports=function(e,t,r,o,i){var s=new Error(e);return n(s,t,r,o,i)}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t){t=t||{};var r={},o=["url","method","params","data"],i=["headers","auth","proxy"],s=["baseURL","url","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"];n.forEach(o,(function(e){void 0!==t[e]&&(r[e]=t[e])})),n.forEach(i,(function(o){n.isObject(t[o])?r[o]=n.deepMerge(e[o],t[o]):void 0!==t[o]?r[o]=t[o]:n.isObject(e[o])?r[o]=n.deepMerge(e[o]):void 0!==e[o]&&(r[o]=e[o])})),n.forEach(s,(function(n){void 0!==t[n]?r[n]=t[n]:void 0!==e[n]&&(r[n]=e[n])}));var u=o.concat(i).concat(s),a=Object.keys(t).filter((function(e){return-1===u.indexOf(e)}));return n.forEach(a,(function(n){void 0!==t[n]?r[n]=t[n]:void 0!==e[n]&&(r[n]=e[n])})),r}},function(e,t,r){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,r){e.exports=r(11)},function(e,t,r){"use strict";r.r(t);var n=r(9);t.default=async(e,t="")=>{const r=encodeURI(e),o=await n.get(`https://cors-anywhere.herokuapp.com/https://tinyurl.com/create.php?source=indexpage&url=${r}&alias=${t}`,{headers:{"X-Requested-With":"XMLHttpRequest"}}),i=document.createElement("html");return i.innerHTML=o.data,i.querySelector("#copy_div").href}},function(e,t,r){"use strict";var n=r(0),o=r(1),i=r(12),s=r(7);function u(e){var t=new i(e),r=o(i.prototype.request,t);return n.extend(r,i.prototype,t),n.extend(r,t),r}var a=u(r(4));a.Axios=i,a.create=function(e){return u(s(a.defaults,e))},a.Cancel=r(8),a.CancelToken=r(26),a.isCancel=r(3),a.all=function(e){return Promise.all(e)},a.spread=r(27),e.exports=a,e.exports.default=a},function(e,t,r){"use strict";var n=r(0),o=r(2),i=r(13),s=r(14),u=r(7);function a(e){this.defaults=e,this.interceptors={request:new i,response:new i}}a.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=u(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[s,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)r=r.then(t.shift(),t.shift());return r},a.prototype.getUri=function(e){return e=u(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){a.prototype[e]=function(t,r){return this.request(n.merge(r||{},{method:e,url:t}))}})),n.forEach(["post","put","patch"],(function(e){a.prototype[e]=function(t,r,o){return this.request(n.merge(o||{},{method:e,url:t,data:r}))}})),e.exports=a},function(e,t,r){"use strict";var n=r(0);function o(){this.handlers=[]}o.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},function(e,t,r){"use strict";var n=r(0),o=r(15),i=r(3),s=r(4);function u(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return u(e),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||s.adapter)(e).then((function(t){return u(e),t.data=o(t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(u(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t,r){return n.forEach(r,(function(r){e=r(e,t)})),e}},function(e,t){var r,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function u(e){if(r===setTimeout)return setTimeout(e,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(e){r=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var a,c=[],f=!1,p=-1;function l(){f&&a&&(f=!1,a.length?c=a.concat(c):p=-1,c.length&&d())}function d(){if(!f){var e=u(l);f=!0;for(var t=c.length;t;){for(a=c,c=[];++p<t;)a&&a[p].run();p=-1,t=c.length}a=null,f=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function m(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new h(e,t)),1!==c.length||f||u(d)},h.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},function(e,t,r){"use strict";var n=r(6);e.exports=function(e,t,r){var o=r.config.validateStatus;!o||o(r.status)?e(r):t(n("Request failed with status code "+r.status,r.config,null,r.request,r))}},function(e,t,r){"use strict";e.exports=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,r){"use strict";var n=r(21),o=r(22);e.exports=function(e,t){return e&&!n(t)?o(e,t):t}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";var n=r(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,i,s={};return e?(n.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=n.trim(e.substr(0,i)).toLowerCase(),r=n.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([r]):s[t]?s[t]+", "+r:r}})),s):s}},function(e,t,r){"use strict";var n=r(0);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=o(window.location.href),function(t){var r=n.isString(t)?o(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},function(e,t,r){"use strict";var n=r(0);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,o,i,s){var u=[];u.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),n.isString(o)&&u.push("path="+o),n.isString(i)&&u.push("domain="+i),!0===s&&u.push("secure"),document.cookie=u.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,r){"use strict";var n=r(8);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}]);
|
|
1
|
+
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=18)}([function(t,e,r){"use strict";var n,o=r(6),i=Object.prototype.toString,s=(n=Object.create(null),function(t){var e=i.call(t);return n[e]||(n[e]=e.slice(8,-1).toLowerCase())});function a(t){return t=t.toLowerCase(),function(e){return s(e)===t}}function u(t){return Array.isArray(t)}function f(t){return void 0===t}var c=a("ArrayBuffer");function h(t){return"number"==typeof t}function l(t){return null!==t&&"object"==typeof t}function p(t){if("object"!==s(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}var d=a("Date"),y=a("File"),g=a("Blob"),m=a("FileList");function v(t){return"[object Function]"===i.call(t)}var w=a("URLSearchParams");function b(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),u(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.call(null,t[o],o,t)}var E,R=(E="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(t){return E&&t instanceof E});var A,T=a("HTMLFormElement"),_=(A=Object.prototype.hasOwnProperty,function(t,e){return A.call(t,e)});t.exports={isArray:u,isArrayBuffer:c,isBuffer:function(t){return null!==t&&!f(t)&&null!==t.constructor&&!f(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return t&&("function"==typeof FormData&&t instanceof FormData||"[object FormData]"===i.call(t)||v(t.toString)&&"[object FormData]"===t.toString())},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&c(t.buffer)},isString:function(t){return"string"==typeof t},isNumber:h,isObject:l,isPlainObject:p,isEmptyObject:function(t){return t&&0===Object.keys(t).length&&Object.getPrototypeOf(t)===Object.prototype},isUndefined:f,isDate:d,isFile:y,isBlob:g,isFunction:v,isStream:function(t){return l(t)&&v(t.pipe)},isURLSearchParams:w,isStandardBrowserEnv:function(){var t;return("undefined"==typeof navigator||"ReactNative"!==(t=navigator.product)&&"NativeScript"!==t&&"NS"!==t)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:b,merge:function t(){var e={};function r(r,n){p(e[n])&&p(r)?e[n]=t(e[n],r):p(r)?e[n]=t({},r):u(r)?e[n]=r.slice():e[n]=r}for(var n=0,o=arguments.length;n<o;n++)b(arguments[n],r);return e},extend:function(t,e,r){return b(e,(function(e,n){t[n]=r&&"function"==typeof e?o(e,r):e})),t},trim:function(t){return t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t},inherits:function(t,e,r,n){t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,r&&Object.assign(t.prototype,r)},toFlatObject:function(t,e,r,n){var o,i,s,a={};if(e=e||{},null==t)return e;do{for(i=(o=Object.getOwnPropertyNames(t)).length;i-- >0;)s=o[i],n&&!n(s,t,e)||a[s]||(e[s]=t[s],a[s]=!0);t=!1!==r&&Object.getPrototypeOf(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},kindOf:s,kindOfTest:a,endsWith:function(t,e,r){t=String(t),(void 0===r||r>t.length)&&(r=t.length),r-=e.length;var n=t.indexOf(e,r);return-1!==n&&n===r},toArray:function(t){if(!t)return null;if(u(t))return t;var e=t.length;if(!h(e))return null;for(var r=new Array(e);e-- >0;)r[e]=t[e];return r},isTypedArray:R,isFileList:m,forEachEntry:function(t,e){for(var r,n=(t&&t[Symbol.iterator]).call(t);(r=n.next())&&!r.done;){var o=r.value;e.call(t,o[0],o[1])}},matchAll:function(t,e){for(var r,n=[];null!==(r=t.exec(e));)n.push(r);return n},isHTMLForm:T,hasOwnProperty:_}},function(t,e,r){"use strict";var n=r(0);function o(t,e,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}n.inherits(o,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var i=o.prototype,s={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((function(t){s[t]={value:t}})),Object.defineProperties(o,s),Object.defineProperty(i,"isAxiosError",{value:!0}),o.from=function(t,e,r,s,a,u){var f=Object.create(i);return n.toFlatObject(t,f,(function(t){return t!==Error.prototype})),o.call(f,t.message,e,r,s,a),f.cause=t,f.name=t.name,u&&Object.assign(f,u),f},t.exports=o},function(t,e,r){"use strict";(function(e){var n=r(0),o=r(1),i=r(26);function s(t){return n.isPlainObject(t)||n.isArray(t)}function a(t){return n.endsWith(t,"[]")?t.slice(0,-2):t}function u(t,e,r){return t?t.concat(e).map((function(t,e){return t=a(t),!r&&e?"["+t+"]":t})).join(r?".":""):e}var f=n.toFlatObject(n,{},null,(function(t){return/^is[A-Z]/.test(t)}));t.exports=function(t,r,c){if(!n.isObject(t))throw new TypeError("target must be an object");r=r||new(i||FormData);var h,l=(c=n.toFlatObject(c,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(t,e){return!n.isUndefined(e[t])}))).metaTokens,p=c.visitor||v,d=c.dots,y=c.indexes,g=(c.Blob||"undefined"!=typeof Blob&&Blob)&&((h=r)&&n.isFunction(h.append)&&"FormData"===h[Symbol.toStringTag]&&h[Symbol.iterator]);if(!n.isFunction(p))throw new TypeError("visitor must be a function");function m(t){if(null===t)return"";if(n.isDate(t))return t.toISOString();if(!g&&n.isBlob(t))throw new o("Blob is not supported. Use a Buffer instead.");return n.isArrayBuffer(t)||n.isTypedArray(t)?g&&"function"==typeof Blob?new Blob([t]):e.from(t):t}function v(t,e,o){var i=t;if(t&&!o&&"object"==typeof t)if(n.endsWith(e,"{}"))e=l?e:e.slice(0,-2),t=JSON.stringify(t);else if(n.isArray(t)&&function(t){return n.isArray(t)&&!t.some(s)}(t)||n.isFileList(t)||n.endsWith(e,"[]")&&(i=n.toArray(t)))return e=a(e),i.forEach((function(t,o){!n.isUndefined(t)&&null!==t&&r.append(!0===y?u([e],o,d):null===y?e:e+"[]",m(t))})),!1;return!!s(t)||(r.append(u(o,e,d),m(t)),!1)}var w=[],b=Object.assign(f,{defaultVisitor:v,convertValue:m,isVisitable:s});if(!n.isObject(t))throw new TypeError("data must be an object");return function t(e,o){if(!n.isUndefined(e)){if(-1!==w.indexOf(e))throw Error("Circular reference detected in "+o.join("."));w.push(e),n.forEach(e,(function(e,i){!0===(!(n.isUndefined(e)||null===e)&&p.call(r,e,n.isString(i)?i.trim():i,o,b))&&t(e,o?o.concat(i):[i])})),w.pop()}}(t),r}}).call(this,r(21).Buffer)},function(t,e,r){"use strict";var n=r(1);function o(t,e,r){n.call(this,null==t?"canceled":t,n.ERR_CANCELED,e,r),this.name="CanceledError"}r(0).inherits(o,n,{__CANCEL__:!0}),t.exports=o},function(t,e,r){"use strict";(function(e){var n=r(0),o=r(9),i=r(1),s=r(10),a=r(2),u=r(32),f=r(5),c=r(11),h={"Content-Type":"application/x-www-form-urlencoded"};function l(t,e){!n.isUndefined(t)&&n.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var p,d={transitional:s,adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==e&&"[object process]"===Object.prototype.toString.call(e))&&(p=r(12)),p),transformRequest:[function(t,e){o(e,"Accept"),o(e,"Content-Type");var r,i=e&&e["Content-Type"]||"",s=i.indexOf("application/json")>-1,f=n.isObject(t);if(f&&n.isHTMLForm(t)&&(t=new FormData(t)),n.isFormData(t))return s?JSON.stringify(c(t)):t;if(n.isArrayBuffer(t)||n.isBuffer(t)||n.isStream(t)||n.isFile(t)||n.isBlob(t))return t;if(n.isArrayBufferView(t))return t.buffer;if(n.isURLSearchParams(t))return l(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString();if(f){if(-1!==i.indexOf("application/x-www-form-urlencoded"))return u(t,this.formSerializer).toString();if((r=n.isFileList(t))||i.indexOf("multipart/form-data")>-1){var h=this.env&&this.env.FormData;return a(r?{"files[]":t}:t,h&&new h,this.formSerializer)}}return f||s?(l(e,"application/json"),function(t,e,r){if(n.isString(t))try{return(e||JSON.parse)(t),n.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(r||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||d.transitional,r=e&&e.forcedJSONParsing,o="json"===this.responseType;if(t&&n.isString(t)&&(r&&!this.responseType||o)){var s=!(e&&e.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(t){if(s){if("SyntaxError"===t.name)throw i.from(t,i.ERR_BAD_RESPONSE,this,null,this.response);throw t}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:f.classes.FormData,Blob:f.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};n.forEach(["delete","get","head"],(function(t){d.headers[t]={}})),n.forEach(["post","put","patch"],(function(t){d.headers[t]=n.merge(h)})),t.exports=d}).call(this,r(31))},function(t,e,r){"use strict";t.exports=r(33)},function(t,e,r){"use strict";t.exports=function(t,e){return function(){return t.apply(e,arguments)}}},function(t,e,r){"use strict";var n=r(0),o=r(8);function i(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}t.exports=function(t,e,r){if(!e)return t;var s=t.indexOf("#");-1!==s&&(t=t.slice(0,s));var a,u=r&&r.encode||i,f=r&&r.serialize;return(a=f?f(e,r):n.isURLSearchParams(e)?e.toString():new o(e,r).toString(u))&&(t+=(-1===t.indexOf("?")?"?":"&")+a),t}},function(t,e,r){"use strict";var n=r(2);function o(t){var e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'\(\)~]|%20|%00/g,(function(t){return e[t]}))}function i(t,e){this._pairs=[],t&&n(t,this,e)}var s=i.prototype;s.append=function(t,e){this._pairs.push([t,e])},s.toString=function(t){var e=t?function(e){return t.call(this,e,o)}:o;return this._pairs.map((function(t){return e(t[0])+"="+e(t[1])}),"").join("&")},t.exports=i},function(t,e,r){"use strict";var n=r(0);t.exports=function(t,e){n.forEach(t,(function(r,n){n!==e&&n.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[n])}))}},function(t,e,r){"use strict";t.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},function(t,e,r){"use strict";var n=r(0);t.exports=function(t){function e(t,r,o,i){var s=t[i++];if("__proto__"===s)return!0;var a=Number.isFinite(+s),u=i>=t.length;return s=!s&&n.isArray(o)?o.length:s,u?(n.hasOwnProperty(o,s)?o[s]=[o[s],r]:o[s]=r,!a):(o[s]&&n.isObject(o[s])||(o[s]=[]),e(t,r,o[s],i)&&n.isArray(o[s])&&(o[s]=function(t){var e,r,n={},o=Object.keys(t),i=o.length;for(e=0;e<i;e++)n[r=o[e]]=t[r];return n}(o[s])),!a)}if(n.isFormData(t)&&n.isFunction(t.entries)){var r={};return n.forEachEntry(t,(function(t,o){e(function(t){return n.matchAll(/\w+|\[(\w*)]/g,t).map((function(t){return"[]"===t[0]?"":t[1]||t[0]}))}(t),o,r,0)})),r}return null}},function(t,e,r){"use strict";var n=r(0),o=r(36),i=r(37),s=r(7),a=r(13),u=r(40),f=r(41),c=r(10),h=r(1),l=r(3),p=r(42),d=r(5);t.exports=function(t){return new Promise((function(e,r){var y,g=t.data,m=t.headers,v=t.responseType,w=t.withXSRFToken;function b(){t.cancelToken&&t.cancelToken.unsubscribe(y),t.signal&&t.signal.removeEventListener("abort",y)}n.isFormData(g)&&n.isStandardBrowserEnv()&&delete m["Content-Type"];var E=new XMLHttpRequest;if(t.auth){var R=t.auth.username||"",A=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";m.Authorization="Basic "+btoa(R+":"+A)}var T=a(t.baseURL,t.url,t.allowAbsoluteUrls);function _(){if(E){var n="getAllResponseHeaders"in E?u(E.getAllResponseHeaders()):null,i={data:v&&"text"!==v&&"json"!==v?E.response:E.responseText,status:E.status,statusText:E.statusText,headers:n,config:t,request:E};o((function(t){e(t),b()}),(function(t){r(t),b()}),i),E=null}}if(E.open(t.method.toUpperCase(),s(T,t.params,t.paramsSerializer),!0),E.timeout=t.timeout,"onloadend"in E?E.onloadend=_:E.onreadystatechange=function(){E&&4===E.readyState&&(0!==E.status||E.responseURL&&0===E.responseURL.indexOf("file:"))&&setTimeout(_)},E.onabort=function(){E&&(r(new h("Request aborted",h.ECONNABORTED,t,E)),E=null)},E.onerror=function(){r(new h("Network Error",h.ERR_NETWORK,t,E)),E=null},E.ontimeout=function(){var e=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",n=t.transitional||c;t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(new h(e,n.clarifyTimeoutError?h.ETIMEDOUT:h.ECONNABORTED,t,E)),E=null},n.isStandardBrowserEnv()&&(w&&n.isFunction(w)&&(w=w(t)),w||!1!==w&&f(T))){var O=t.xsrfHeaderName&&t.xsrfCookieName&&i.read(t.xsrfCookieName);O&&(m[t.xsrfHeaderName]=O)}"setRequestHeader"in E&&n.forEach(m,(function(t,e){void 0===g&&"content-type"===e.toLowerCase()?delete m[e]:E.setRequestHeader(e,t)})),n.isUndefined(t.withCredentials)||(E.withCredentials=!!t.withCredentials),v&&"json"!==v&&(E.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&E.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&E.upload&&E.upload.addEventListener("progress",t.onUploadProgress),(t.cancelToken||t.signal)&&(y=function(e){E&&(r(!e||e.type?new l(null,t,E):e),E.abort(),E=null)},t.cancelToken&&t.cancelToken.subscribe(y),t.signal&&(t.signal.aborted?y():t.signal.addEventListener("abort",y))),g||!1===g||0===g||""===g||(g=null);var S=p(T);S&&-1===d.protocols.indexOf(S)?r(new h("Unsupported protocol "+S+":",h.ERR_BAD_REQUEST,t)):E.send(g)}))}},function(t,e,r){"use strict";var n=r(38),o=r(39);t.exports=function(t,e,r){var i=!n(e);return t&&(i||!1===r)?o(t,e):e}},function(t,e,r){"use strict";t.exports=function(t){return!(!t||!t.__CANCEL__)}},function(t,e,r){"use strict";var n=r(0);t.exports=function(t,e){e=e||{};var r={};function o(t,e){return n.isPlainObject(t)&&n.isPlainObject(e)?n.merge(t,e):n.isEmptyObject(e)?n.merge({},t):n.isPlainObject(e)?n.merge({},e):n.isArray(e)?e.slice():e}function i(r){return n.isUndefined(e[r])?n.isUndefined(t[r])?void 0:o(void 0,t[r]):o(t[r],e[r])}function s(t){if(!n.isUndefined(e[t]))return o(void 0,e[t])}function a(r){return n.isUndefined(e[r])?n.isUndefined(t[r])?void 0:o(void 0,t[r]):o(void 0,e[r])}function u(r){return r in e?o(t[r],e[r]):r in t?o(void 0,t[r]):void 0}var f={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:u};return n.forEach(Object.keys(t).concat(Object.keys(e)),(function(t){var e=f[t]||i,o=e(t);n.isUndefined(o)&&e!==u||(r[t]=o)})),r}},function(t,e){t.exports={version:"0.30.2"}},function(t,e,r){t.exports=r(19)},function(t,e,r){"use strict";r.r(e);var n=r(17);e.default=async(t,e="")=>{if("string"!=typeof t||""===t.trim())throw new TypeError("The 'url' parameter must be a non-empty string.");e&&console.warn("TinyURL alias parameter is not supported when using tinyurl-rest-wrapper. The alias will be ignored and a random slug will be generated instead.");try{const e=await n.post("https://tinyurl-rest-wrapper.onrender.com/",{url:t},{headers:{"Content-Type":"application/json"}});if(!e.data||"string"!=typeof e.data.tinyurl)throw new Error("Invalid response from TinyURL service.");return e.data.tinyurl}catch(t){if(t instanceof TypeError)throw t;throw new Error("Failed to shorten URL: "+(t.message||"Unknown error"))}}},function(t,e,r){"use strict";var n=r(0),o=r(6),i=r(20),s=r(15),a=r(4),u=r(11);var f=function t(e){var r=new i(e),a=o(i.prototype.request,r);return n.extend(a,i.prototype,r),n.extend(a,r),a.create=function(r){return t(s(e,r))},a}(a);f.Axios=i,f.CanceledError=r(3),f.CancelToken=r(44),f.isCancel=r(14),f.VERSION=r(16).version,f.toFormData=r(2),f.AxiosError=r(1),f.Cancel=f.CanceledError,f.all=function(t){return Promise.all(t)},f.spread=r(45),f.isAxiosError=r(46),f.formToJSON=function(t){return u(n.isHTMLForm(t)?new FormData(t):t)},t.exports=f,t.exports.default=f},function(t,e,r){"use strict";var n=r(0),o=r(7),i=r(28),s=r(29),a=r(15),u=r(13),f=r(43),c=f.validators;function h(t){this.defaults=t,this.interceptors={request:new i,response:new i}}h.prototype.request=function(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;void 0!==r&&f.assertOptions(r,{silentJSONParsing:c.transitional(c.boolean),forcedJSONParsing:c.transitional(c.boolean),clarifyTimeoutError:c.transitional(c.boolean)},!1);var o=e.paramsSerializer;null!=o&&(n.isFunction(o)?e.paramsSerializer={serialize:o}:f.assertOptions(o,{encode:c.function,serialize:c.function},!0));var i=[],u=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(u=u&&t.synchronous,i.unshift(t.fulfilled,t.rejected))}));var h,l=[];if(this.interceptors.response.forEach((function(t){l.push(t.fulfilled,t.rejected)})),!u){var p=[s,void 0];for(Array.prototype.unshift.apply(p,i),p=p.concat(l),h=Promise.resolve(e);p.length;)h=h.then(p.shift(),p.shift());return h}for(var d=e;i.length;){var y=i.shift(),g=i.shift();try{d=y(d)}catch(t){g(t);break}}try{h=s(d)}catch(t){return Promise.reject(t)}for(;l.length;)h=h.then(l.shift(),l.shift());return h},h.prototype.getUri=function(t){t=a(this.defaults,t);var e=u(t.baseURL,t.url,t.allowAbsoluteUrls);return o(e,t.params,t.paramsSerializer)},n.forEach(["delete","get","head","options"],(function(t){h.prototype[t]=function(e,r){return this.request(a(r||{},{method:t,url:e,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(t){function e(e){return function(r,n,o){return this.request(a(o||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}h.prototype[t]=e(),h.prototype[t+"Form"]=e(!0)})),t.exports=h},function(t,e,r){"use strict";(function(t){
|
|
2
|
+
/*!
|
|
3
|
+
* The buffer module from node.js, for the browser.
|
|
4
|
+
*
|
|
5
|
+
* @author Feross Aboukhadijeh <http://feross.org>
|
|
6
|
+
* @license MIT
|
|
7
|
+
*/
|
|
8
|
+
var n=r(23),o=r(24),i=r(25);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return h(this,t)}return f(this,t,e,r)}function f(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=l(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(e,r),o=(t=a(t,n)).write(e,r);o!==n&&(t=t.slice(0,o));return t}(t,e,r):function(t,e){if(u.isBuffer(e)){var r=0|p(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):l(t,e);if("Buffer"===e.type&&i(e.data))return l(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function h(t,e){if(c(e),t=a(t,e<0?0:0|p(e)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function l(t,e){var r=e.length<0?0:0|p(e.length);t=a(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function p(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function d(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return M(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(t).length;default:if(n)return M(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,r);case"utf8":case"utf-8":return O(this,e,r);case"ascii":return S(this,e,r);case"latin1":case"binary":return x(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function m(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,o);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var c=-1;for(i=r;i<a;i++)if(f(t,i)===f(e,-1===c?0:i-c)){if(-1===c&&(c=i),i-c+1===u)return c*s}else-1!==c&&(i-=i-c),c=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var h=!0,l=0;l<u;l++)if(f(t,i+l)!==f(e,l)){h=!1;break}if(h)return i}return-1}function w(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function b(t,e,r,n){return z(M(e,t.length-r),t,r,n)}function E(t,e,r,n){return z(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function R(t,e,r,n){return E(t,e,r,n)}function A(t,e,r,n){return z(Y(e),t,r,n)}function T(t,e,r,n){return z(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function _(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function O(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,a,u,f=t[o],c=null,h=f>239?4:f>223?3:f>191?2:1;if(o+h<=r)switch(h){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(c=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&f)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&f)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(c=u)}null===c?(c=65533,h=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=h}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,r){return f(null,t,e,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,r){return function(t,e,r,n){return c(e),e<=0?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}(null,t,e,r)},u.allocUnsafe=function(t){return h(null,t)},u.allocUnsafeSlow=function(t){return h(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!i(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=u.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},u.byteLength=d,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)g(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?O(this,0,t):y.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,r,n,o){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),f=this.slice(n,o),c=t.slice(e,r),h=0;h<a;++h)if(f[h]!==c[h]){i=f[h],s=c[h];break}return i<s?-1:s<i?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return m(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return m(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return E(this,t,e,r);case"latin1":case"binary":return R(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function S(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function x(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function P(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=k(t[i]);return o}function B(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function U(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function j(t,e,r,n){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);o<i;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function L(t,e,r,n){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);o<i;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function D(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,r,n,i){return i||D(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,i){return i||D(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=u.prototype;else{var o=e-t;r=new u(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+t]}return r},u.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||U(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},u.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||U(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUInt8=function(t,e){return e||U(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||U(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||U(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||U(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||U(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||U(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||U(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return e||U(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||U(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){e||U(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return e||U(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||U(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||U(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||U(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||U(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||U(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):j(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):j(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):L(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):L(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);C(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);C(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):j(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):j(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):L(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):L(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o,i=n-r;if(this===t&&r<e&&e<n)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var s=u.isBuffer(t)?t:M(new u(t,n).toString()),a=s.length;for(i=0;i<r-e;++i)this[i+e]=s[i%a]}return this};var I=/[^+\/0-9A-Za-z-_]/g;function k(t){return t<16?"0"+t.toString(16):t.toString(16)}function M(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function Y(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}}).call(this,r(22))},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";e.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,n=f(t),s=n[0],a=n[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),c=0,h=a>0?s-4:s;for(r=0;r<h;r+=4)e=o[t.charCodeAt(r)]<<18|o[t.charCodeAt(r+1)]<<12|o[t.charCodeAt(r+2)]<<6|o[t.charCodeAt(r+3)],u[c++]=e>>16&255,u[c++]=e>>8&255,u[c++]=255&e;2===a&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,u[c++]=255&e);1===a&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,u[c++]=e>>8&255,u[c++]=255&e);return u},e.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(c(t,s,s+16383>a?a:s+16383));1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function f(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var o,i,s=[],a=e;a<r;a+=3)o=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,f=u>>1,c=-7,h=r?o-1:0,l=r?-1:1,p=t[e+h];for(h+=l,i=p&(1<<-c)-1,p>>=-c,c+=a;c>0;i=256*i+t[e+h],h+=l,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=n;c>0;s=256*s+t[e+h],h+=l,c-=8);if(0===i)i=1-f;else{if(i===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=f}return(p?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,a,u,f=8*i-o-1,c=(1<<f)-1,h=c>>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(e*u-1)*Math.pow(2,o),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;t[r+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,f+=o;f>0;t[r+p]=255&s,p+=d,s/=256,f-=8);t[r+p-d]|=128*y}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){t.exports=r(27)},function(t,e,r){"use strict";t.exports="object"==typeof self?self.FormData:window.FormData},function(t,e,r){"use strict";var n=r(0);function o(){this.handlers=[]}o.prototype.use=function(t,e,r){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},o.prototype.clear=function(){this.handlers&&(this.handlers=[])},o.prototype.forEach=function(t){n.forEach(this.handlers,(function(e){null!==e&&t(e)}))},t.exports=o},function(t,e,r){"use strict";var n=r(0),o=r(30),i=r(14),s=r(4),a=r(3),u=r(9);function f(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new a}t.exports=function(t){return f(t),t.headers=t.headers||{},t.data=o.call(t,t.data,t.headers,null,t.transformRequest),u(t.headers,"Accept"),u(t.headers,"Content-Type"),t.headers=n.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||s.adapter)(t).then((function(e){return f(t),e.data=o.call(t,e.data,e.headers,e.status,t.transformResponse),e}),(function(e){return i(e)||(f(t),e&&e.response&&(e.response.data=o.call(t,e.response.data,e.response.headers,e.response.status,t.transformResponse))),Promise.reject(e)}))}},function(t,e,r){"use strict";var n=r(0),o=r(4);t.exports=function(t,e,r,i){var s=this||o;return n.forEach(i,(function(n){t=n.call(s,t,e,r)})),t}},function(t,e){var r,n,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(r===setTimeout)return setTimeout(t,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(t){r=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(t){n=s}}();var u,f=[],c=!1,h=-1;function l(){c&&u&&(c=!1,u.length?f=u.concat(f):h=-1,f.length&&p())}function p(){if(!c){var t=a(l);c=!0;for(var e=f.length;e;){for(u=f,f=[];++h<e;)u&&u[h].run();h=-1,e=f.length}u=null,c=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function y(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];f.push(new d(t,e)),1!==f.length||c||a(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e,r){"use strict";var n=r(0),o=r(2),i=r(5);t.exports=function(t,e){return o(t,new i.classes.URLSearchParams,Object.assign({visitor:function(t,e,r,o){return i.isNode&&n.isBuffer(t)?(this.append(e,t.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},e))}},function(t,e,r){"use strict";t.exports={isBrowser:!0,classes:{URLSearchParams:r(34),FormData:r(35),Blob:Blob},protocols:["http","https","file","blob","url","data"]}},function(t,e,r){"use strict";var n=r(8);t.exports="undefined"!=typeof URLSearchParams?URLSearchParams:n},function(t,e,r){"use strict";t.exports=FormData},function(t,e,r){"use strict";var n=r(1);t.exports=function(t,e,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?e(new n("Request failed with status code "+r.status,[n.ERR_BAD_REQUEST,n.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):t(r)}},function(t,e,r){"use strict";var n=r(0);t.exports=n.isStandardBrowserEnv()?{write:function(t,e,r,o,i,s){var a=[];a.push(t+"="+encodeURIComponent(e)),n.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),n.isString(o)&&a.push("path="+o),n.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(t,e,r){"use strict";t.exports=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}},function(t,e,r){"use strict";t.exports=function(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}},function(t,e,r){"use strict";var n=r(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(t){var e,r,i,s={};return t?(n.forEach(t.split("\n"),(function(t){if(i=t.indexOf(":"),e=n.trim(t.slice(0,i)).toLowerCase(),r=n.trim(t.slice(i+1)),e){if(s[e]&&o.indexOf(e)>=0)return;s[e]="set-cookie"===e?(s[e]?s[e]:[]).concat([r]):s[e]?s[e]+", "+r:r}})),s):s}},function(t,e,r){"use strict";var n=r(0);t.exports=n.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(t){var n=t;return e&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return t=o(window.location.href),function(e){var r=n.isString(e)?o(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0}},function(t,e,r){"use strict";t.exports=function(t){var e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}},function(t,e,r){"use strict";var n=r(16).version,o=r(1),i={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){i[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}}));var s={};i.transitional=function(t,e,r){function i(t,e){return"[Axios v"+n+"] Transitional option '"+t+"'"+e+(r?". "+r:"")}return function(r,n,a){if(!1===t)throw new o(i(n," has been removed"+(e?" in "+e:"")),o.ERR_DEPRECATED);return e&&!s[n]&&(s[n]=!0,console.warn(i(n," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,n,a)}},t.exports={assertOptions:function(t,e,r){if("object"!=typeof t)throw new o("options must be an object",o.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(t),i=n.length;i-- >0;){var s=n[i],a=e[s];if(a){var u=t[s],f=void 0===u||a(u,s,t);if(!0!==f)throw new o("option "+s+" must be "+f,o.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new o("Unknown option "+s,o.ERR_BAD_OPTION)}},validators:i}},function(t,e,r){"use strict";var n=r(3);function o(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;this.promise.then((function(t){if(r._listeners){for(var e=r._listeners.length;e-- >0;)r._listeners[e](t);r._listeners=null}})),this.promise.then=function(t){var e,n=new Promise((function(t){r.subscribe(t),e=t})).then(t);return n.cancel=function(){r.unsubscribe(e)},n},t((function(t,o,i){r.reason||(r.reason=new n(t,o,i),e(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},o.prototype.unsubscribe=function(t){if(this._listeners){var e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}},o.source=function(){var t;return{token:new o((function(e){t=e})),cancel:t}},t.exports=o},function(t,e,r){"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}},function(t,e,r){"use strict";var n=r(0);t.exports=function(t){return n.isObject(t)&&!0===t.isAxiosError}}]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kulkul/tinyurl-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "TinyURL JavaScript client",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"module": "dist/main.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"axios": "^0.
|
|
18
|
+
"axios": "^0.30.2",
|
|
19
19
|
"chai": "^4.2.0",
|
|
20
20
|
"cheerio": "^1.0.0-rc.3",
|
|
21
21
|
"esm": "^3.2.25",
|
package/src/index.js
CHANGED
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
import * as axios from "axios";
|
|
2
2
|
|
|
3
3
|
const shortenUrl = async (url, alias = "") => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
// Validate input
|
|
5
|
+
if (typeof url !== "string" || url.trim() === "") {
|
|
6
|
+
throw new TypeError("The 'url' parameter must be a non-empty string.");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (alias) {
|
|
10
|
+
console.warn(
|
|
11
|
+
"TinyURL alias parameter is not supported when using tinyurl-rest-wrapper. " +
|
|
12
|
+
"The alias will be ignored and a random slug will be generated instead."
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const response = await axios.post(
|
|
18
|
+
"https://tinyurl-rest-wrapper.onrender.com/",
|
|
19
|
+
{ url },
|
|
20
|
+
{ headers: { "Content-Type": "application/json" } }
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
// Validate response structure
|
|
24
|
+
if (!response.data || typeof response.data.tinyurl !== "string") {
|
|
25
|
+
throw new Error("Invalid response from TinyURL service.");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return response.data.tinyurl;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
// Re-throw with more context if it's not already a TypeError
|
|
31
|
+
if (error instanceof TypeError) {
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
throw new Error(
|
|
35
|
+
`Failed to shorten URL: ${error.message || "Unknown error"}`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
13
38
|
};
|
|
14
39
|
|
|
15
40
|
export default shortenUrl;
|
package/tests/index.test.js
CHANGED
|
@@ -1,201 +1,24 @@
|
|
|
1
1
|
import * as axios from "axios";
|
|
2
2
|
import * as chai from "chai";
|
|
3
|
-
import cheerio from "cheerio";
|
|
4
3
|
import sinon from "sinon";
|
|
5
4
|
import shortenUrl from "../src";
|
|
6
5
|
|
|
7
6
|
const { expect } = chai;
|
|
8
7
|
|
|
9
8
|
describe("Shorten URL", () => {
|
|
10
|
-
let tinyUrlResponseStub;
|
|
11
|
-
const tinyUrlResponse = (alias = "ydyofn2z") =>
|
|
12
|
-
"<!DOCTYPE html>\n" +
|
|
13
|
-
'<html lang="en">\n' +
|
|
14
|
-
"<head>\n" +
|
|
15
|
-
' <meta charset="UTF-8">\n' +
|
|
16
|
-
"<!--[if IE]><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><![endif]-->\n" +
|
|
17
|
-
'<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">\n' +
|
|
18
|
-
"<title>TinyURL.com - shorten that long URL into a tiny URL</title>\n" +
|
|
19
|
-
'<base href="https://tinyurl.com/">\n' +
|
|
20
|
-
'<meta name="description" content="TinyURL.com is the original URL shortener that shortens your unwieldly links into more manageable and useable URLs.">\n' +
|
|
21
|
-
'<meta name="keywords" content="tinyurl url save share shorten analyze">\n' +
|
|
22
|
-
'<link rel="shortcut icon" href="https://tinyurl.com/favicon.ico" type="image/gif"> <meta name="robots" content="nofollow">\n' +
|
|
23
|
-
"\n" +
|
|
24
|
-
"\n" +
|
|
25
|
-
' <link href="https://tinyurl.com/css/legacy/app.css" rel="stylesheet" type="text/css" />\n' +
|
|
26
|
-
' <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>\n' +
|
|
27
|
-
' <script type="text/javascript">\n' +
|
|
28
|
-
" document.write('<script async type=\"text/javascript\" src=\"https://tinyurl.com/siteresources/js/common.js\"></sc'+'ript>');\n" +
|
|
29
|
-
" </script>\n" +
|
|
30
|
-
"\n" +
|
|
31
|
-
' <script src="//tags-cdn.deployads.com/a/tinyurl.com.js" async ></script>\n' +
|
|
32
|
-
"\n" +
|
|
33
|
-
"<!-- Facebook Pixel Code -->\n" +
|
|
34
|
-
"<script>\n" +
|
|
35
|
-
" !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n" +
|
|
36
|
-
" n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;\n" +
|
|
37
|
-
" n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;\n" +
|
|
38
|
-
" t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,\n" +
|
|
39
|
-
" document,'script','https://connect.facebook.net/en_US/fbevents.js');\n" +
|
|
40
|
-
" fbq('init', '196261077476671');\n" +
|
|
41
|
-
" fbq('track', 'PageView');\n" +
|
|
42
|
-
"</script>\n" +
|
|
43
|
-
'<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=196261077476671&ev=PageView&noscript=1"/></noscript>\n' +
|
|
44
|
-
"<!-- DO NOT MODIFY -->\n" +
|
|
45
|
-
"<!-- End Facebook Pixel Code --><!-- Repixel Code -->\n" +
|
|
46
|
-
"<script>\n" +
|
|
47
|
-
" (function(w, d, s, id, src){\n" +
|
|
48
|
-
" w.Repixel = r = {\n" +
|
|
49
|
-
" init: function(id) {\n" +
|
|
50
|
-
" w.repixelId = id;\n" +
|
|
51
|
-
" }\n" +
|
|
52
|
-
" };\n" +
|
|
53
|
-
" var js, fjs = d.getElementsByTagName(s)[0];\n" +
|
|
54
|
-
" if (d.getElementById(id)){ return; }\n" +
|
|
55
|
-
" js = d.createElement(s); \n" +
|
|
56
|
-
" js.id = id;\n" +
|
|
57
|
-
" js.async = true;\n" +
|
|
58
|
-
" js.onload = function(){\n" +
|
|
59
|
-
" Repixel.init(w.repixelId);\n" +
|
|
60
|
-
" };\n" +
|
|
61
|
-
" js.src = src;\n" +
|
|
62
|
-
" fjs.parentNode.insertBefore(js, fjs);\n" +
|
|
63
|
-
" }(window, document, 'script', 'repixel', \n" +
|
|
64
|
-
" 'https://sdk.repixel.co/r.js'));\n" +
|
|
65
|
-
" Repixel.init('5cefdb1c7e39460007a3db07');\n" +
|
|
66
|
-
"</script>\n" +
|
|
67
|
-
"<!-- END Repixel Code -->\n" +
|
|
68
|
-
"<!-- Widgetly pixel --> <script src='https://pixel.widgetly.com/static/track.js?acc=ad0e0a2e5a30b8c6cf75dfe9baa73f5a43faa0' async=''></script> <!--END Widgetly pixel --></head>\n" +
|
|
69
|
-
"\n" +
|
|
70
|
-
"<body>\n" +
|
|
71
|
-
' <script type="text/javascript">\n' +
|
|
72
|
-
"\n" +
|
|
73
|
-
" var _gaq = _gaq || [];\n" +
|
|
74
|
-
" _gaq.push(['_setAccount', 'UA-6779119-1']);\n" +
|
|
75
|
-
" _gaq.push(['_trackPageview']);\n" +
|
|
76
|
-
"\n" +
|
|
77
|
-
" (function() {\n" +
|
|
78
|
-
" var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n" +
|
|
79
|
-
" ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';\n" +
|
|
80
|
-
" var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n" +
|
|
81
|
-
" })();\n" +
|
|
82
|
-
"\n" +
|
|
83
|
-
'</script> <div id="alert_new_ui">\n' +
|
|
84
|
-
' Try <a href="https://tinyurl.com/app">new UI</a>\n' +
|
|
85
|
-
" </div>\n" +
|
|
86
|
-
' <div class="wrapper">\n' +
|
|
87
|
-
' <div class="header">\n' +
|
|
88
|
-
" <h1>\n" +
|
|
89
|
-
' <a class="baselink" href="https://tinyurl.com">\n' +
|
|
90
|
-
' <img src="https://tinyurl.com/siteresources/images/tinyurl_logo.png" alt="TinyURL.com"/>\n' +
|
|
91
|
-
" </a>\n" +
|
|
92
|
-
" </h1>\n" +
|
|
93
|
-
" Making over a billion long URLs usable! Serving billions of redirects per month. </div>\n" +
|
|
94
|
-
' <div class="body">\n' +
|
|
95
|
-
' <div class="leftpane">\n' +
|
|
96
|
-
' <div class="sidebar">\n' +
|
|
97
|
-
' <div><a class="baselink" href="https://tinyurl.com">Home</a></div>\n' +
|
|
98
|
-
' <div><a href="/#example">Example</a></div>\n' +
|
|
99
|
-
' <div><a href="/#toolbar">Make Toolbar Button</a></div>\n' +
|
|
100
|
-
' <div><a href="/#redirect">Redirection</a></div>\n' +
|
|
101
|
-
' <div><a href="/preview.php">Preview Feature</a><sup><small style="font-weight: bold">cool!</small></sup></div>\n' +
|
|
102
|
-
' <div><a href="/#link">Link to Us!</a></div>\n' +
|
|
103
|
-
' <div><a href="/#terms">Terms of use</a></div>\n' +
|
|
104
|
-
' <div><a href="/articles/index.html">Articles</a></div>\n' +
|
|
105
|
-
' <div><a href="/cdn-cgi/l/email-protection#05767075756a777145716c6b7c7077692b666a68">Contact Us!</a></div>\n' +
|
|
106
|
-
" </div>\n" +
|
|
107
|
-
' <div class="ad-tag" data-ad-name="Sortable Left Sidebar" data-ad-size="160x600" data-ad-demand=\'!g\' data-ad-refresh="user time 30s"></div>\n' +
|
|
108
|
-
'<script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script src="//tags-cdn.deployads.com/a/tinyurl.com.js" async ></script>\n' +
|
|
109
|
-
"<script>(deployads = window.deployads || []).push({});</script></div>\n" +
|
|
110
|
-
' <div class="mainpane">\n' +
|
|
111
|
-
' <div class="topbanner">\n' +
|
|
112
|
-
' <div class="ad-tag" data-ad-name="Sortable Leaderboard" data-ad-size="728x90" data-ad-demand="!g" data-ad-refresh="user time 30s" ></div>\n' +
|
|
113
|
-
' <script src="//tags-cdn.deployads.com/a/tinyurl.com.js" async ></script>\n' +
|
|
114
|
-
" <script>(deployads = window.deployads || []).push({});</script>\n" +
|
|
115
|
-
" </div>\n" +
|
|
116
|
-
' <div class="maincontent">\n' +
|
|
117
|
-
' <div class="rightad">\n' +
|
|
118
|
-
' <div class="ad-tag" data-ad-name="Sortable_Right_Sidebar" data-ad-size="300x250" data-ad-demand="!g" data-ad-refresh="user time 30s" ></div>\n' +
|
|
119
|
-
' <script src="//tags-cdn.deployads.com/a/tinyurl.com.js" async ></script>\n' +
|
|
120
|
-
" <script>(deployads = window.deployads || []).push({});</script>\n" +
|
|
121
|
-
"<br><br>\n" +
|
|
122
|
-
"<div class='widgetlyOnPageSnippet' id='widgetlyOP-765-929' style=\"width: 300px;padding: 0px;\"></div>\n" +
|
|
123
|
-
" </div>\n" +
|
|
124
|
-
' <div id="contentcontainer">\n' +
|
|
125
|
-
" <h1>TinyURL was created!</h1>\n" +
|
|
126
|
-
" <p>The following URL:</p>\n" +
|
|
127
|
-
' <div class="indent longurl">\n' +
|
|
128
|
-
" <b>https://kulkul.tech</b>\n" +
|
|
129
|
-
" </div>\n" +
|
|
130
|
-
" has a length of 19 characters and resulted in the following TinyURL which has a length of 28 characters:\n" +
|
|
131
|
-
` <div class="indent"><b>https://tinyurl.com/${alias}</b><div id="success"></div><br><small>[<a href="https://tinyurl.com/${alias}" target="_blank" rel="nofollow">Open in new window</a>]</small><a id="copy_div" href="https://tinyurl.com/${alias}" onclick="return false;" data-clipboard-text="https://tinyurl.com/${alias}"><small>[Copy to clipboard]</small></a></div>\n` +
|
|
132
|
-
" Or, give your recipients confidence with a preview TinyURL:\n" +
|
|
133
|
-
` <div class="indent"><b>https://preview.tinyurl.com/${alias}</b><br>\n` +
|
|
134
|
-
` <small>[<a href="https://preview.tinyurl.com/${alias}" target="_blank">Open in new window</a>]</small>\n` +
|
|
135
|
-
" </div><p></p>\n" +
|
|
136
|
-
` <div class="copyinfo" data-clipboard-text="https://tinyurl.com/${alias}"><i><b>How to copy and paste the TinyURL:</b> To copy the TinyURL to your clipboard, right click the link under the TinyURL and select the copy link location option. To paste the TinyURL into a document, press Ctrl and V on your keyboard, or select "paste" from the edit menu of the program you are using.</i></div>\n` +
|
|
137
|
-
"\n" +
|
|
138
|
-
" \n" +
|
|
139
|
-
' <form action="https://tinyurl.com/create.php" method="get" name="f" id="f" class="create-form">\n' +
|
|
140
|
-
" <b>Enter a long URL to make tiny:</b><br />\n" +
|
|
141
|
-
' <input type="hidden" id="source" name="source" value="create">\n' +
|
|
142
|
-
' <input type="text" id="url" name="url" value="">\n' +
|
|
143
|
-
' <input type="submit" value="Make TinyURL!">\n' +
|
|
144
|
-
" <hr>Custom alias (optional):<br />\n" +
|
|
145
|
-
' <tt class="basecontent">https://tinyurl.com/</tt>\n' +
|
|
146
|
-
' <input type="text" id="alias" name="alias" value="" maxlength="30"><br />\n' +
|
|
147
|
-
" <small>May contain letters, numbers, and dashes.</small>\n" +
|
|
148
|
-
"</form>\n" +
|
|
149
|
-
" <div class='widgetlyOnPageSnippet' id='widgetlyOP-766-932'></div><div class='widgetlyOnPageSnippet' id='widgetlyOP-766-931'></div><div class='widgetlyOnPageSnippet' id='widgetlyOP-766-930'></div>\n" +
|
|
150
|
-
" </div>\n" +
|
|
151
|
-
' <div style="clear:both"></div>\n' +
|
|
152
|
-
" </div>\n" +
|
|
153
|
-
" </div>\n" +
|
|
154
|
-
" </div>\n" +
|
|
155
|
-
' <div class="push"></div>\n' +
|
|
156
|
-
" </div>\n" +
|
|
157
|
-
"\n" +
|
|
158
|
-
' <div class="footer">\n' +
|
|
159
|
-
' <div class="privacy"><a id="privacy" href="https://tinyurl.com/privaicy.php">Privacy policy</a></div>\n' +
|
|
160
|
-
' <div id="copyright">Copyright © 2002-2020 TinyURL, LLC. All rights reserved.<br> TinyURL is a trademark of TinyURL, LLC.</div>\n' +
|
|
161
|
-
" </div>\n" +
|
|
162
|
-
" <script>\n" +
|
|
163
|
-
" var cookies = document.cookie ? document.cookie.split('; ') : [];\n" +
|
|
164
|
-
" for (var i = 0; i < cookies.length; i++) {\n" +
|
|
165
|
-
" var parts = cookies[i].split('=');\n" +
|
|
166
|
-
" if(parts[0] === 'invite') {\n" +
|
|
167
|
-
" $('#alert_new_ui').show();\n" +
|
|
168
|
-
" }\n" +
|
|
169
|
-
" }\n" +
|
|
170
|
-
" </script>\n" +
|
|
171
|
-
' <script src="/js/legacy/app.js?id=688d20dfacce6c0c0d40"></script>\n' +
|
|
172
|
-
"</body>\n" +
|
|
173
|
-
"</html>";
|
|
174
|
-
|
|
175
9
|
describe("Create short URL without alias", () => {
|
|
10
|
+
let axiosPostStub;
|
|
11
|
+
|
|
176
12
|
before(() => {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
Object.create({
|
|
181
|
-
innerHTML: "",
|
|
182
|
-
querySelector: function () {
|
|
183
|
-
const $ = cheerio.load(this.innerHTML);
|
|
184
|
-
const href = $("#copy_div").attr("href");
|
|
185
|
-
return { href };
|
|
186
|
-
},
|
|
187
|
-
}),
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
tinyUrlResponseStub = sinon
|
|
191
|
-
.stub(axios, "get")
|
|
192
|
-
.returns({ data: tinyUrlResponse() });
|
|
13
|
+
axiosPostStub = sinon
|
|
14
|
+
.stub(axios, "post")
|
|
15
|
+
.returns({ data: { tinyurl: "https://tinyurl.com/ydyofn2z" } });
|
|
193
16
|
});
|
|
194
17
|
|
|
195
18
|
after(() => {
|
|
196
|
-
|
|
197
|
-
tinyUrlResponseStub.restore();
|
|
19
|
+
axiosPostStub.restore();
|
|
198
20
|
});
|
|
21
|
+
|
|
199
22
|
it("should be able to shorten url using TinyURL", async () => {
|
|
200
23
|
const url = "https://kulkul.tech";
|
|
201
24
|
const response = await shortenUrl(url);
|
|
@@ -203,34 +26,79 @@ describe("Shorten URL", () => {
|
|
|
203
26
|
});
|
|
204
27
|
});
|
|
205
28
|
|
|
206
|
-
describe("Create short URL with alias", () => {
|
|
29
|
+
describe("Create short URL with alias (deprecated)", () => {
|
|
30
|
+
let axiosPostStub;
|
|
31
|
+
|
|
207
32
|
before(() => {
|
|
208
|
-
//
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
innerHTML: "",
|
|
213
|
-
querySelector: function () {
|
|
214
|
-
const $ = cheerio.load(this.innerHTML);
|
|
215
|
-
const href = $("#copy_div").attr("href");
|
|
216
|
-
return { href };
|
|
217
|
-
},
|
|
218
|
-
}),
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
tinyUrlResponseStub = sinon
|
|
222
|
-
.stub(axios, "get")
|
|
223
|
-
.returns({ data: tinyUrlResponse("shorted-kulkul") });
|
|
33
|
+
// Mock returns a random slug since aliases are not supported
|
|
34
|
+
axiosPostStub = sinon
|
|
35
|
+
.stub(axios, "post")
|
|
36
|
+
.returns({ data: { tinyurl: "https://tinyurl.com/abc123xyz" } });
|
|
224
37
|
});
|
|
225
38
|
|
|
226
39
|
after(() => {
|
|
227
|
-
|
|
228
|
-
tinyUrlResponseStub.restore();
|
|
40
|
+
axiosPostStub.restore();
|
|
229
41
|
});
|
|
230
|
-
|
|
42
|
+
|
|
43
|
+
it("should ignore alias parameter and return random slug", async () => {
|
|
231
44
|
const url = "https://kulkul.tech";
|
|
232
45
|
const response = await shortenUrl(url, "shorted-kulkul");
|
|
233
|
-
|
|
46
|
+
// The alias is ignored and a random slug is returned
|
|
47
|
+
expect(response).to.be.equal("https://tinyurl.com/abc123xyz");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("Error handling", () => {
|
|
52
|
+
let axiosPostStub;
|
|
53
|
+
|
|
54
|
+
afterEach(() => {
|
|
55
|
+
if (axiosPostStub) {
|
|
56
|
+
axiosPostStub.restore();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("should throw error for empty URL", async () => {
|
|
61
|
+
try {
|
|
62
|
+
await shortenUrl("");
|
|
63
|
+
expect.fail("Should have thrown an error");
|
|
64
|
+
} catch (error) {
|
|
65
|
+
expect(error.message).to.include("non-empty string");
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("should throw error for non-string URL", async () => {
|
|
70
|
+
try {
|
|
71
|
+
await shortenUrl(null);
|
|
72
|
+
expect.fail("Should have thrown an error");
|
|
73
|
+
} catch (error) {
|
|
74
|
+
expect(error.message).to.include("non-empty string");
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("should handle API errors gracefully", async () => {
|
|
79
|
+
axiosPostStub = sinon
|
|
80
|
+
.stub(axios, "post")
|
|
81
|
+
.rejects(new Error("Network error"));
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
await shortenUrl("https://kulkul.tech");
|
|
85
|
+
expect.fail("Should have thrown an error");
|
|
86
|
+
} catch (error) {
|
|
87
|
+
expect(error.message).to.include("Failed to shorten URL");
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("should handle invalid response structure", async () => {
|
|
92
|
+
axiosPostStub = sinon
|
|
93
|
+
.stub(axios, "post")
|
|
94
|
+
.returns({ data: { invalid: "response" } });
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
await shortenUrl("https://kulkul.tech");
|
|
98
|
+
expect.fail("Should have thrown an error");
|
|
99
|
+
} catch (error) {
|
|
100
|
+
expect(error.message).to.include("Invalid response");
|
|
101
|
+
}
|
|
234
102
|
});
|
|
235
103
|
});
|
|
236
104
|
});
|