ruffle/web/packages/core/test/swf-file-name.ts

21 lines
619 B
TypeScript
Raw Normal View History

import { strict as assert } from "assert";
2023-04-24 10:27:03 +00:00
import { swfFileName } from "../src/swf-utils";
describe("swfFileName", function () {
it("should extract simple SWF name", function () {
assert.deepEqual(nameFor("http://example.com/file.swf"), "file.swf");
});
it("should not include query parameters", function () {
assert.deepEqual(
nameFor(
2023-07-20 11:19:39 +00:00
"https://uploads.ungrounded.net/574000/574241_DiamondNGSP.swf?123",
),
2023-07-20 11:19:39 +00:00
"574241_DiamondNGSP.swf",
);
});
});
function nameFor(url: string): string {
return swfFileName(new URL(url));
}