MCPcopy Create free account
hub / github.com/cloudinary/cloudinary_npm / finalize_source

Function finalize_source

lib/utils/index.js:931–952  ·  view source on GitHub ↗
(source, format, url_suffix)

Source from the content-addressed store, hash-verified

929}
930
931function finalize_source(source, format, url_suffix) {
932 let source_to_sign;
933 source = source.replace(/([^:])\/\//g, '$1/');
934 if (source.match(/^https?:\//i)) {
935 source = smart_escape(source);
936 source_to_sign = source;
937 } else {
938 source = encodeURIComponent(decodeURIComponent(source)).replace(/%3A/g, ":").replace(/%2F/g, "/");
939 source_to_sign = source;
940 if (url_suffix) {
941 if (url_suffix.match(/[\.\/]/)) {
942 throw new Error('url_suffix should not include . or /');
943 }
944 source = source + '/' + url_suffix;
945 }
946 if (format != null) {
947 source = source + '.' + format;
948 source_to_sign = source_to_sign + '.' + format;
949 }
950 }
951 return [source, source_to_sign];
952}
953
954function video_thumbnail_url(public_id, options) {
955 options = extend({}, DEFAULT_POSTER_OPTIONS, options);

Callers 1

urlFunction · 0.85

Calls 1

smart_escapeFunction · 0.85

Tested by

no test coverage detected