mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
fixing url concatenation bug
This commit is contained in:
parent
ca33bb1efb
commit
0e3b04c122
@ -90,14 +90,14 @@ export class Utils {
|
||||
continue;
|
||||
}
|
||||
|
||||
const part = args[i].replace('\\', '/');
|
||||
const part = args[i].replace(new RegExp('\\\\', 'g'), '/');
|
||||
if (part === '/' || part === './') {
|
||||
continue;
|
||||
}
|
||||
|
||||
url += part + '/';
|
||||
}
|
||||
url = url.replace('//', '/');
|
||||
url = url.replace(new RegExp('/+', 'g'), '/');
|
||||
|
||||
if (url.trim() === '') {
|
||||
url = './';
|
||||
|
18
test/common/unit/Utils.spec.ts
Normal file
18
test/common/unit/Utils.spec.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import {expect} from 'chai';
|
||||
import {Utils} from '../../../common/Utils';
|
||||
|
||||
describe('Utils', () => {
|
||||
it('should concat urls', () => {
|
||||
expect(Utils.concatUrls('abc', 'cde')).to.be.equal('abc/cde');
|
||||
expect(Utils.concatUrls('abc/', 'cde')).to.be.equal('abc/cde');
|
||||
expect(Utils.concatUrls('abc\\', 'cde')).to.be.equal('abc/cde');
|
||||
expect(Utils.concatUrls('abc/', 'cde/')).to.be.equal('abc/cde');
|
||||
expect(Utils.concatUrls('./abc\\', 'cde/')).to.be.equal('./abc/cde');
|
||||
expect(Utils.concatUrls('abc/', '\\cde/')).to.be.equal('abc/cde');
|
||||
expect(Utils.concatUrls('abc\\', '\\cde/')).to.be.equal('abc/cde');
|
||||
expect(Utils.concatUrls('abc\\', '/cde/')).to.be.equal('abc/cde');
|
||||
expect(Utils.concatUrls('abc/', '/cde/')).to.be.equal('abc/cde');
|
||||
expect(Utils.concatUrls('abc\\/', '/cde/')).to.be.equal('abc/cde');
|
||||
expect(Utils.concatUrls('abc\\/', '/cde/', 'fgh')).to.be.equal('abc/cde/fgh');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user