Socket
Socket
Sign inDemoInstall

unsplash-js

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unsplash-js - npm Package Compare versions

Comparing version 7.0.1 to 7.0.2

2

CHANGELOG.md

@@ -47,2 +47,4 @@ # Changelog

- ❌ `updateProfile`
- `stats`:
- ❌ `total`
- ❌ `toJson` (the library now takes care of converting the response to JSON).

@@ -49,0 +51,0 @@

2

dist/helpers/url.d.ts

@@ -8,3 +8,3 @@ declare type Query = {

};
export declare const buildUrl: ({ pathname, query }: BuildUrlParams) => (apiBaseUrl: string) => string;
export declare const buildUrl: ({ pathname, query }: BuildUrlParams) => (apiUrl: string) => string;
export declare const parseQueryAndPathname: (url: string) => {

@@ -11,0 +11,0 @@ query: Query;

@@ -191,7 +191,20 @@ 'use strict';

var addPathnameToUrl = function addPathnameToUrl(pathname) {
return function (url) {
// When there is no existing pathname, the value is `/`. Appending would give us a URL with two
// forward slashes. This is why we replace the value in that scenario.
if (url.pathname === '/') {
url.pathname = pathname;
} else {
url.pathname += pathname;
}
};
};
var buildUrl = function buildUrl(_ref) {
var pathname = _ref.pathname,
query = _ref.query;
return function (apiBaseUrl) {
var url = new URL(pathname, apiBaseUrl);
return function (apiUrl) {
var url = new URL(apiUrl);
addPathnameToUrl(pathname)(url);
addQueryToUrl(query)(url);

@@ -198,0 +211,0 @@ return url.toString();

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("content-type");function n(){return(n=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function t(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n.indexOf(t=o[r])>=0||(a[t]=e[t]);return a}var r=o((function(e){return"string"==typeof e?e:null})),a=function(e){return null!=e};function o(e){return function(n){return a(e(n))}}var s=function(e){return Object.keys(e).reduce((function(t,r){var o,s=e[r];return n({},t,a(s)?((o={})[r]=s,o):{})}),{})};function i(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=n.length-1;return function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];for(var o=n[0].apply(this,t),s=1;s<=r;s++)o=n[s].call(this,o);return o}}var u,l,c=o((function(e){return a(e)&&"object"==typeof e&&!Array.isArray(e)?e:null})),h=o((function(e){return Array.isArray(e)&&e.every(r)&&e.length>0?e:null})),p=o((function(e){return c(e)&&"errors"in e&&h(e.errors)?{errors:e.errors}:null})),d=function(e){this.message=e},f=function(n){if(function(n){var t=n.headers.get("content-type");return a(t)&&"application/json"===e.parse(t).type}(n))return n.json().catch((function(e){throw new d("unable to parse JSON response.")}));throw new d("expected JSON response from server.")},g=function(){return function(e){return f(e.response)}},y=function(e){return function(r,a){void 0===a&&(a={});var o=e(r),s=o.headers,i=o.query;return n({},t(o,["headers","query"]),a,{query:i,headers:n({},s,a.headers)})}},m=function(e){var r=e.accessKey,o=e.apiVersion,s=void 0===o?"v1":o,u=e.apiUrl,l=void 0===u?"https://api.unsplash.com":u,c=e.headers,h=e.fetch,g=t(e,["accessKey","apiVersion","apiUrl","headers","fetch"]);return function(e){var t=e.handleResponse;return i(e.handleRequest,(function(e){var o=e.method,i=void 0===o?"GET":o,u=e.headers,y=e.body,m=e.signal,v=function(e){var n=e.pathname,t=e.query;return function(e){var r=new URL(n,e);return function(e){return function(n){Object.keys(e).forEach((function(t){return n.searchParams.set(t,e[t].toString())}))}}(t)(r),r.toString()}}({pathname:e.pathname,query:e.query})(l),q=n({method:i,headers:n({},c,u,{"Accept-Version":s},a(r)?{Authorization:"Client-ID "+r}:{}),body:y,signal:m},g);return(null!=h?h:fetch)(v,q).then(function(e){return function(t){return(t.ok?e({response:t}).then((function(e){return{type:"success",status:t.status,response:e}})):f(t).then((function(e){return n({type:"error",status:t.status},function(e){return p(e)?{errors:e.errors,source:"api"}:{errors:["Responded with a status code outside the 2xx range, and the response body is not recognisable."],source:"decoding"}}(e))}))).catch((function(e){if(e instanceof d)return{type:"error",source:"decoding",status:t.status,errors:[e.message]};throw e}))}}(t))}))}},v=function(e){var n=e.headers.get("x-total");if(a(n)){var t=parseInt(n);if(Number.isInteger(t))return t;throw new d("expected x-total header to be valid integer.")}throw new d("expected x-total header to exist.")},q=function(){return function(e){var n=e.response;return g()({response:n}).then((function(e){return{results:e,total:v(n)}}))}},R=function(e){return a(e)?{collections:e.join()}:{}},w=function(e){return s({per_page:e.perPage,order_by:e.orderBy,page:e.page})},b={handleRequest:y((function(e){var r=e.collectionId,a=e.orientation,o=t(e,["collectionId","orientation"]);return{pathname:"/collections/"+r+"/photos",query:s(n({},w(o),{orientation:a}))}})),handleResponse:q()},k={handleRequest:y((function(e){return{pathname:"/collections/"+e.collectionId,query:{}}})),handleResponse:g()},_={handleRequest:y((function(e){return void 0===e&&(e={}),{pathname:"/collections",query:w(e)}})),handleResponse:q()},P={handleRequest:y((function(e){return{pathname:"/collections/"+e.collectionId+"/related",query:{}}})),handleResponse:g()},S={__proto__:null,getPhotos:b,get:k,list:_,getRelated:P},I={handleRequest:y((function(e){return void 0===e&&(e={}),{pathname:"/photos",query:s(w(e))}})),handleResponse:q()},x={handleRequest:y((function(e){return{pathname:"/photos/"+e.photoId,query:{}}})),handleResponse:g()},A={handleRequest:y((function(e){return{pathname:"/photos/"+e.photoId+"/statistics",query:{}}})),handleResponse:g()},j={handleRequest:y((function(e){var r=void 0===e?{}:e,a=r.collectionIds,o=t(r,["collectionIds"]);return{pathname:"/photos/random",query:s(n({},o,R(a))),headers:{"cache-control":"no-cache"}}})),handleResponse:g()},L={handleRequest:y((function(e){var n=function(e){var n=new URL(e),t=n.pathname,r={};return n.searchParams.forEach((function(e,n){r[n]=e})),{query:r,pathname:"/"===t?void 0:t}}(e.downloadLocation),t=n.pathname,r=n.query;if(!a(t))throw new Error("Could not parse pathname from url.");return{pathname:t,query:s(r)}})),handleResponse:g()},O={__proto__:null,list:I,get:x,getStats:A,getRandom:j,trackDownload:L},C={handleRequest:y((function(e){var r=e.query,a=e.page,o=e.perPage,i=e.orderBy,u=e.collectionIds,l=e.lang,c=e.contentFilter,h=t(e,["query","page","perPage","orderBy","collectionIds","lang","contentFilter"]);return{pathname:"/search/photos",query:s(n({query:r,content_filter:c,lang:l,order_by:i},w({page:a,perPage:o}),R(u),h))}})),handleResponse:g()},T={handleRequest:y((function(e){var r=e.query,a=t(e,["query"]);return{pathname:"/search/collections",query:n({query:r},w(a))}})),handleResponse:g()},z={handleRequest:y((function(e){var r=e.query,a=t(e,["query"]);return{pathname:"/search/users",query:n({query:r},w(a))}})),handleResponse:g()},U={__proto__:null,getPhotos:C,getCollections:T,getUsers:z},B={handleRequest:y((function(e){return{pathname:"/users/"+e.username,query:{}}})),handleResponse:g()},E={handleRequest:y((function(e){var r=e.username,a=e.stats,o=e.orientation,i=t(e,["username","stats","orientation"]);return{pathname:"/users/"+r+"/photos",query:s(n({},w(i),{orientation:o,stats:a}))}})),handleResponse:q()},M={handleRequest:y((function(e){var r=e.username,a=e.orientation,o=t(e,["username","orientation"]);return{pathname:"/users/"+r+"/likes",query:s(n({},w(o),{orientation:a}))}})),handleResponse:q()},K={handleRequest:y((function(e){var n=e.username,r=t(e,["username"]);return{pathname:"/users/"+n+"/collections",query:w(r)}})),handleResponse:q()},H={__proto__:null,collections:S,photos:O,search:U,users:{__proto__:null,get:B,getPhotos:E,getLikes:M,getCollections:K},trackNonHotLinkedPhotoView:function(e){var n=e.appId;return function(e){var t=e.photoId,r=Array.isArray(t)?t:[t];if(r.length>20)throw new Error("You cannot track more than 20 photos at once. Please try again with fewer photos.");return fetch("views.unsplash.com/v?photo_id="+r.join()+"&app_id="+n)}}};(u=exports.Language||(exports.Language={})).Afrikaans="af",u.Amharic="am",u.Arabic="ar",u.Azerbaijani="az",u.Belarusian="be",u.Bulgarian="bg",u.Bengali="bn",u.Bosnian="bs",u.Catalan="ca",u.Cebuano="ceb",u.Corsican="co",u.Czech="cs",u.Welsh="cy",u.Danish="da",u.German="de",u.Greek="el",u.English="en",u.Esperanto="eo",u.Spanish="es",u.Estonian="et",u.Basque="eu",u.Persian="fa",u.Finnish="fi",u.French="fr",u.Frisian="fy",u.Irish="ga",u.ScotsGaelic="gd",u.Galician="gl",u.Gujarati="gu",u.Hausa="ha",u.Hawaiian="haw",u.Hindi="hi",u.Hmong="hmn",u.Croatian="hr",u.HaitianCreole="ht",u.Hungarian="hu",u.Armenian="hy",u.Indonesian="id",u.Igbo="ig",u.Icelandic="is",u.Italian="it",u.Hebrew="iw",u.Japanese="ja",u.Javanese="jw",u.Georgian="ka",u.Kazakh="kk",u.Khmer="km",u.Kannada="kn",u.Korean="ko",u.Kurdish="ku",u.Kyrgyz="ky",u.Latin="la",u.Luxembourgish="lb",u.Lao="lo",u.Lithuanian="lt",u.Latvian="lv",u.Malagasy="mg",u.Maori="mi",u.Macedonian="mk",u.Malayalam="ml",u.Mongolian="mn",u.Marathi="mr",u.Malay="ms",u.Maltese="mt",u.Myanmar="my",u.Nepali="ne",u.Dutch="nl",u.Norwegian="no",u.Nyanja="ny",u.Oriya="or",u.Punjabi="pa",u.Polish="pl",u.Pashto="ps",u.Portuguese="pt",u.Romanian="ro",u.Russian="ru",u.Kinyarwanda="rw",u.Sindhi="sd",u.Sinhala="si",u.Slovak="sk",u.Slovenian="sl",u.Samoan="sm",u.Shona="sn",u.Somali="so",u.Albanian="sq",u.Serbian="sr",u.Sesotho="st",u.Sundanese="su",u.Swedish="sv",u.Swahili="sw",u.Tamil="ta",u.Telugu="te",u.Tajik="tg",u.Thai="th",u.Turkmen="tk",u.Filipino="tl",u.Turkish="tr",u.Tatar="tt",u.Uighur="ug",u.Ukrainian="uk",u.Urdu="ur",u.Uzbek="uz",u.Vietnamese="vi",u.Xhosa="xh",u.Yiddish="yi",u.Yoruba="yo",u.ChineseSimplified="zh",u.ChineseTraditional="zh-TW",u.Zulu="zu",(l=exports.OrderBy||(exports.OrderBy={})).LATEST="latest",l.POPULAR="popular",l.OLDEST="oldest";var G=i(m,(function(e){return{photos:{get:e(x),list:e(I),getStats:e(A),getRandom:e(j),trackDownload:e(L)},users:{getPhotos:e(E),getCollections:e(K),getLikes:e(M),get:e(B)},search:{getCollections:e(T),getPhotos:e(C),getUsers:e(z)},collections:{getPhotos:e(b),get:e(k),list:e(_),getRelated:e(P)}}}));exports._internals=H,exports.createApi=G;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("content-type");function n(){return(n=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function t(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n.indexOf(t=o[r])>=0||(a[t]=e[t]);return a}var r=o((function(e){return"string"==typeof e?e:null})),a=function(e){return null!=e};function o(e){return function(n){return a(e(n))}}var s=function(e){return Object.keys(e).reduce((function(t,r){var o,s=e[r];return n({},t,a(s)?((o={})[r]=s,o):{})}),{})};function i(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=n.length-1;return function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];for(var o=n[0].apply(this,t),s=1;s<=r;s++)o=n[s].call(this,o);return o}}var u,l,c=o((function(e){return a(e)&&"object"==typeof e&&!Array.isArray(e)?e:null})),h=o((function(e){return Array.isArray(e)&&e.every(r)&&e.length>0?e:null})),p=o((function(e){return c(e)&&"errors"in e&&h(e.errors)?{errors:e.errors}:null})),d=function(e){this.message=e},f=function(n){if(function(n){var t=n.headers.get("content-type");return a(t)&&"application/json"===e.parse(t).type}(n))return n.json().catch((function(e){throw new d("unable to parse JSON response.")}));throw new d("expected JSON response from server.")},g=function(){return function(e){return f(e.response)}},y=function(e){return function(r,a){void 0===a&&(a={});var o=e(r),s=o.headers,i=o.query;return n({},t(o,["headers","query"]),a,{query:i,headers:n({},s,a.headers)})}},m=function(e){var r=e.accessKey,o=e.apiVersion,s=void 0===o?"v1":o,u=e.apiUrl,l=void 0===u?"https://api.unsplash.com":u,c=e.headers,h=e.fetch,g=t(e,["accessKey","apiVersion","apiUrl","headers","fetch"]);return function(e){var t=e.handleResponse;return i(e.handleRequest,(function(e){var o=e.method,i=void 0===o?"GET":o,u=e.headers,y=e.body,m=e.signal,v=function(e){var n=e.pathname,t=e.query;return function(e){var r=new URL(e);return function(e){return function(n){"/"===n.pathname?n.pathname=e:n.pathname+=e}}(n)(r),function(e){return function(n){Object.keys(e).forEach((function(t){return n.searchParams.set(t,e[t].toString())}))}}(t)(r),r.toString()}}({pathname:e.pathname,query:e.query})(l),q=n({method:i,headers:n({},c,u,{"Accept-Version":s},a(r)?{Authorization:"Client-ID "+r}:{}),body:y,signal:m},g);return(null!=h?h:fetch)(v,q).then(function(e){return function(t){return(t.ok?e({response:t}).then((function(e){return{type:"success",status:t.status,response:e}})):f(t).then((function(e){return n({type:"error",status:t.status},function(e){return p(e)?{errors:e.errors,source:"api"}:{errors:["Responded with a status code outside the 2xx range, and the response body is not recognisable."],source:"decoding"}}(e))}))).catch((function(e){if(e instanceof d)return{type:"error",source:"decoding",status:t.status,errors:[e.message]};throw e}))}}(t))}))}},v=function(e){var n=e.headers.get("x-total");if(a(n)){var t=parseInt(n);if(Number.isInteger(t))return t;throw new d("expected x-total header to be valid integer.")}throw new d("expected x-total header to exist.")},q=function(){return function(e){var n=e.response;return g()({response:n}).then((function(e){return{results:e,total:v(n)}}))}},R=function(e){return a(e)?{collections:e.join()}:{}},w=function(e){return s({per_page:e.perPage,order_by:e.orderBy,page:e.page})},b={handleRequest:y((function(e){var r=e.collectionId,a=e.orientation,o=t(e,["collectionId","orientation"]);return{pathname:"/collections/"+r+"/photos",query:s(n({},w(o),{orientation:a}))}})),handleResponse:q()},k={handleRequest:y((function(e){return{pathname:"/collections/"+e.collectionId,query:{}}})),handleResponse:g()},_={handleRequest:y((function(e){return void 0===e&&(e={}),{pathname:"/collections",query:w(e)}})),handleResponse:q()},P={handleRequest:y((function(e){return{pathname:"/collections/"+e.collectionId+"/related",query:{}}})),handleResponse:g()},S={__proto__:null,getPhotos:b,get:k,list:_,getRelated:P},I={handleRequest:y((function(e){return void 0===e&&(e={}),{pathname:"/photos",query:s(w(e))}})),handleResponse:q()},x={handleRequest:y((function(e){return{pathname:"/photos/"+e.photoId,query:{}}})),handleResponse:g()},A={handleRequest:y((function(e){return{pathname:"/photos/"+e.photoId+"/statistics",query:{}}})),handleResponse:g()},j={handleRequest:y((function(e){var r=void 0===e?{}:e,a=r.collectionIds,o=t(r,["collectionIds"]);return{pathname:"/photos/random",query:s(n({},o,R(a))),headers:{"cache-control":"no-cache"}}})),handleResponse:g()},L={handleRequest:y((function(e){var n=function(e){var n=new URL(e),t=n.pathname,r={};return n.searchParams.forEach((function(e,n){r[n]=e})),{query:r,pathname:"/"===t?void 0:t}}(e.downloadLocation),t=n.pathname,r=n.query;if(!a(t))throw new Error("Could not parse pathname from url.");return{pathname:t,query:s(r)}})),handleResponse:g()},O={__proto__:null,list:I,get:x,getStats:A,getRandom:j,trackDownload:L},C={handleRequest:y((function(e){var r=e.query,a=e.page,o=e.perPage,i=e.orderBy,u=e.collectionIds,l=e.lang,c=e.contentFilter,h=t(e,["query","page","perPage","orderBy","collectionIds","lang","contentFilter"]);return{pathname:"/search/photos",query:s(n({query:r,content_filter:c,lang:l,order_by:i},w({page:a,perPage:o}),R(u),h))}})),handleResponse:g()},T={handleRequest:y((function(e){var r=e.query,a=t(e,["query"]);return{pathname:"/search/collections",query:n({query:r},w(a))}})),handleResponse:g()},z={handleRequest:y((function(e){var r=e.query,a=t(e,["query"]);return{pathname:"/search/users",query:n({query:r},w(a))}})),handleResponse:g()},U={__proto__:null,getPhotos:C,getCollections:T,getUsers:z},B={handleRequest:y((function(e){return{pathname:"/users/"+e.username,query:{}}})),handleResponse:g()},E={handleRequest:y((function(e){var r=e.username,a=e.stats,o=e.orientation,i=t(e,["username","stats","orientation"]);return{pathname:"/users/"+r+"/photos",query:s(n({},w(i),{orientation:o,stats:a}))}})),handleResponse:q()},M={handleRequest:y((function(e){var r=e.username,a=e.orientation,o=t(e,["username","orientation"]);return{pathname:"/users/"+r+"/likes",query:s(n({},w(o),{orientation:a}))}})),handleResponse:q()},K={handleRequest:y((function(e){var n=e.username,r=t(e,["username"]);return{pathname:"/users/"+n+"/collections",query:w(r)}})),handleResponse:q()},H={__proto__:null,collections:S,photos:O,search:U,users:{__proto__:null,get:B,getPhotos:E,getLikes:M,getCollections:K},trackNonHotLinkedPhotoView:function(e){var n=e.appId;return function(e){var t=e.photoId,r=Array.isArray(t)?t:[t];if(r.length>20)throw new Error("You cannot track more than 20 photos at once. Please try again with fewer photos.");return fetch("views.unsplash.com/v?photo_id="+r.join()+"&app_id="+n)}}};(u=exports.Language||(exports.Language={})).Afrikaans="af",u.Amharic="am",u.Arabic="ar",u.Azerbaijani="az",u.Belarusian="be",u.Bulgarian="bg",u.Bengali="bn",u.Bosnian="bs",u.Catalan="ca",u.Cebuano="ceb",u.Corsican="co",u.Czech="cs",u.Welsh="cy",u.Danish="da",u.German="de",u.Greek="el",u.English="en",u.Esperanto="eo",u.Spanish="es",u.Estonian="et",u.Basque="eu",u.Persian="fa",u.Finnish="fi",u.French="fr",u.Frisian="fy",u.Irish="ga",u.ScotsGaelic="gd",u.Galician="gl",u.Gujarati="gu",u.Hausa="ha",u.Hawaiian="haw",u.Hindi="hi",u.Hmong="hmn",u.Croatian="hr",u.HaitianCreole="ht",u.Hungarian="hu",u.Armenian="hy",u.Indonesian="id",u.Igbo="ig",u.Icelandic="is",u.Italian="it",u.Hebrew="iw",u.Japanese="ja",u.Javanese="jw",u.Georgian="ka",u.Kazakh="kk",u.Khmer="km",u.Kannada="kn",u.Korean="ko",u.Kurdish="ku",u.Kyrgyz="ky",u.Latin="la",u.Luxembourgish="lb",u.Lao="lo",u.Lithuanian="lt",u.Latvian="lv",u.Malagasy="mg",u.Maori="mi",u.Macedonian="mk",u.Malayalam="ml",u.Mongolian="mn",u.Marathi="mr",u.Malay="ms",u.Maltese="mt",u.Myanmar="my",u.Nepali="ne",u.Dutch="nl",u.Norwegian="no",u.Nyanja="ny",u.Oriya="or",u.Punjabi="pa",u.Polish="pl",u.Pashto="ps",u.Portuguese="pt",u.Romanian="ro",u.Russian="ru",u.Kinyarwanda="rw",u.Sindhi="sd",u.Sinhala="si",u.Slovak="sk",u.Slovenian="sl",u.Samoan="sm",u.Shona="sn",u.Somali="so",u.Albanian="sq",u.Serbian="sr",u.Sesotho="st",u.Sundanese="su",u.Swedish="sv",u.Swahili="sw",u.Tamil="ta",u.Telugu="te",u.Tajik="tg",u.Thai="th",u.Turkmen="tk",u.Filipino="tl",u.Turkish="tr",u.Tatar="tt",u.Uighur="ug",u.Ukrainian="uk",u.Urdu="ur",u.Uzbek="uz",u.Vietnamese="vi",u.Xhosa="xh",u.Yiddish="yi",u.Yoruba="yo",u.ChineseSimplified="zh",u.ChineseTraditional="zh-TW",u.Zulu="zu",(l=exports.OrderBy||(exports.OrderBy={})).LATEST="latest",l.POPULAR="popular",l.OLDEST="oldest";var G=i(m,(function(e){return{photos:{get:e(x),list:e(I),getStats:e(A),getRandom:e(j),trackDownload:e(L)},users:{getPhotos:e(E),getCollections:e(K),getLikes:e(M),get:e(B)},search:{getCollections:e(T),getPhotos:e(C),getUsers:e(z)},collections:{getPhotos:e(b),get:e(k),list:e(_),getRelated:e(P)}}}));exports._internals=H,exports.createApi=G;
//# sourceMappingURL=unsplash-js.cjs.production.min.js.map

@@ -187,7 +187,20 @@ import { parse } from 'content-type';

var addPathnameToUrl = function addPathnameToUrl(pathname) {
return function (url) {
// When there is no existing pathname, the value is `/`. Appending would give us a URL with two
// forward slashes. This is why we replace the value in that scenario.
if (url.pathname === '/') {
url.pathname = pathname;
} else {
url.pathname += pathname;
}
};
};
var buildUrl = function buildUrl(_ref) {
var pathname = _ref.pathname,
query = _ref.query;
return function (apiBaseUrl) {
var url = new URL(pathname, apiBaseUrl);
return function (apiUrl) {
var url = new URL(apiUrl);
addPathnameToUrl(pathname)(url);
addQueryToUrl(query)(url);

@@ -194,0 +207,0 @@ return url.toString();

{
"name": "unsplash-js",
"version": "7.0.1",
"version": "7.0.2",
"description": "Official JavaScript wrapper for the Unsplash API",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -77,4 +77,10 @@ # Unsplash

Make sure to polyfill this interface if targetting older environments that do not implement it (i.e. Internet Explorer or a Node version older than [v8](https://nodejs.org/es/blog/release/v8.0.0/#say-hello-to-the-whatwg-url-parser))
Note: Make sure to polyfill this interface if targetting older environments that do not implement it (i.e. Internet Explorer or Node < v8).
Note 2: For Node, the URL interface exists under `require('url').URL` since [v8](https://nodejs.org/es/blog/release/v8.0.0/#say-hello-to-the-whatwg-url-parser) but was only added to the global scope as of [v10.0.0](https://nodejs.org/docs/latest/api/globals.html#globals_url). If you are using a version between v8.0.0 and v10.0.0, you need to add the class to the global scope before using `unsplash-js`:
```js
URL = require('url').URL;
```
## Usage

@@ -411,3 +417,3 @@

unsplash.photos.trackDownload({
downloadLocation: photo.links.downloadLocation,
downloadLocation: photo.links.download_location,
});

@@ -422,3 +428,3 @@ }

unsplash.photos.trackDownload({
downloadLocation: photo.links.downloadLocation,
downloadLocation: photo.links.download_location,
});

@@ -425,0 +431,0 @@ }

@@ -16,4 +16,15 @@ type Query = {

export const buildUrl = ({ pathname, query }: BuildUrlParams) => (apiBaseUrl: string) => {
const url = new URL(pathname, apiBaseUrl);
const addPathnameToUrl = (pathname: string) => (url: URL) => {
// When there is no existing pathname, the value is `/`. Appending would give us a URL with two
// forward slashes. This is why we replace the value in that scenario.
if (url.pathname === '/') {
url.pathname = pathname;
} else {
url.pathname += pathname;
}
};
export const buildUrl = ({ pathname, query }: BuildUrlParams) => (apiUrl: string) => {
const url = new URL(apiUrl);
addPathnameToUrl(pathname)(url);
addQueryToUrl(query)(url);

@@ -20,0 +31,0 @@ return url.toString();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc