You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
parttimejob/node_modules/ali-oss/lib/common/object/getObjectUrl.js

22 lines
665 B

const { isIP } = require('../utils/isIP');
const proto = exports;
/**
* Get Object url by name
* @param {String} name - object name
* @param {String} [baseUrl] - If provide `baseUrl`,
* will use `baseUrl` instead the default `endpoint`.
* @return {String} object url
*/
proto.getObjectUrl = function getObjectUrl(name, baseUrl) {
if (isIP(this.options.endpoint.hostname)) {
throw new Error('can not get the object URL when endpoint is IP');
}
if (!baseUrl) {
baseUrl = this.options.endpoint.format();
} else if (baseUrl[baseUrl.length - 1] !== '/') {
baseUrl += '/';
}
return baseUrl + this._escape(this._objectName(name));
};